Recently I saw an awesome blog post by Dustin Smerdon on how to create Dynamic Reference Areas based on a Parameter. His method uses a Dual axis, and some clever calculations to achieve it. I highly recommend going to check it out, and subscribing to his blog (I'm sure more great things are coming!). https://betaviz.wordpress.com/2017/09/05/how-to-dynamic-reference-areas/
I wanted to try and replicate the end result using a different method. Below is the How To using a Reference Line.
Step 1.
Create a Parameter that allows the user to switch between Quarters.
I have made this Parameter and Integer, and used the Display Alias to show the User the options by Quarter. I am doing this to make life easier in a Later Calculation.
Step 2.
Create a calculated field that will be used as our "Reference Line"
If you look at this Calculated Field, you can see why I chose to use an Integer Parameter. Here I am simply saying that if the Quarter of my Order Date is equal to the Quarter the User Selected in the Parameter, than give me 0 else give NULL. I want that the 3 other quarters will not generate a value, but the quarter selected will generate a 0.
Step 3.
Plot the fields.
*Important Note* in order for this method to work, we need to use a Discrete Date on our Columns Shelf.
Step 4.
Add the Reference Line
What we need to do is first set the Reference Line to compute using Cell, so that is that calculates on each Month of Order Date (This is why having a Discrete Date field is necessary). From here, we remove the line and the label, and tell Tableau to Shade Above.
If you remember, our calculation tells Tableau that if the Quarter Date Part of our Order Date equals our Parameter, we want to give a Value of 0. So in the Reference Line, Tableau is creating a Reference Line for each Month that is in the chosen Quarter at the 0 point, and we are simply shading above it, giving the illusion of a Shaded Bar Chart.
This method has limitations, but allows us to Free up the second Axis, in case we want to use it for a Combo Chart. Example below with a different Quarter selected.
Hope this helps.
Rody





1 Comment
Very cool, Rody!
Balas