Fixed Reference Band/Line and Date Filters
At Inviso, we have free Alteryx and Tableau support for our customers, which means our customers can write us anytime and get help with their data problems. On the support, we often get to solve some really cool problems for our clients and this blog post is actually explaining the solution to a problem, we got on our support mail a while ago.
The Problem:Our client had made a time line in Tableau showing sales. In the view he also had a reference band showing the date range for their sales campaign. His view looked something like this:
The problem arose when he started filtering on the date range, because the reference band persisted, which meant the axis did not follow the time line, but stayed at the maximum/minimum of the reference band. When he started to filter out the date range, his view would look something like this:
To solve this problem, we needed to find a way to make the reference band disappear if the dates of the reference band were filtered out. Fortunately, the solution was actually pretty straight forward!
The Solution:The first step is to make two variables, one for the campaign start date and one for the end date. The two calculations look like this:
Next step is to make a calculation conditional on the dates showed in the view. If the date range in the view is not containing the range of the reference band, we do not want to see it. This logic is implemented in the calculations below:
Now we can use these calculations to specify the reference band. To make the reference band, drag the calculations, you just made, on Detail on the Marks card. Notice the fields are blue, which means they are discrete. If your date in the view is green, that is, continuous (as in this example), you need to right-click on the fields and select "Continuous". When clicking "Continuous", they should turn green.
Add the reference band by right clicking on the axis and select "Add Reference Line". In the new window, click "Band" and configure the window as below:
Voila! Now the reference band should follow your filter. The solution is by the way also applicable for the same problem with reference lines.
If you understand Danish and would like a thorough explanation of the solution above, my colleague has made a video explaining how to solve the problem.