How to create Step chart in Tableau, without unioning/modeling your data.
This example is going to use Vanilla SuperStore, no modelling, just as it is out of the box.
To begin, we have to understand what a Step Chart is, and why is can be difficult to create it in Tableau.
All in all, it's a pretty simple chart. The problem, however, is the fact that we need 2 data points for each segment on the X axis. In this example, I'm using Months. Normally, we could do this by Unioning our Data to itself, so that we can create a path. But this requires work, and we have to literally double the size of our dataset. Since that's not what I want to do, let look at how we can build it just using Tableau.
The first step we need to do is figure out how to get two marks on the Month, where one is equal to the Current Month, and the Other is equal to the Next Month.
To begin, let drag Order Date (Months) onto the Columns shelf, and Sales on the Row Shelf.
Pretty simple, but we somehow need to get the Next Months Value into the Same "partition". So we can do that using a Lookup function.
LOOKUP(SUM([Sales]),1)
*You can also use the Previous Value using LOOKUP(SUM([Sales]),-1), depending on where you want the Line, or Flat line to fall.
*You can also use the Previous Value using LOOKUP(SUM([Sales]),-1), depending on where you want the Line, or Flat line to fall.
Place that onto the same axis as Sales, so that Measure Name/Values are generated.
So now we have 2 values for each month: one that represents the current month, and one that represents the next month. At this point, the lines are being connected by the Measure Names along Month, so we need to change that so that it connects the measures then goes across through the months.
We can do this using an INDEX() function that we place on the Path mark.
Cool, this is much closer, but it's not what we want. See Tableau is using an INDEX() from the Next Value first, then the Sales Value. And it is the same in each Month, so to correct this, so Tableau draws it the way we want, we simply swap the order of the Measure in the Measure Values shelf, thus making Sales first, and Next Values sales second.
*If you used Previous Value instead of Next Value, you'd want to leave Previous Value first in the order on the Measure Values shelf.
*If you used Previous Value instead of Next Value, you'd want to leave Previous Value first in the order on the Measure Values shelf.
And just like that, we have a Step Chart in Tableau without needing to do any data modeling.
Hope this helps!
Rody





3 Comment
Great! I really love this kind of tips :D
BalasThank you Rody! I like the way you describe the tricks - so simple! I just used this kind of chart for makeovermonday ;)
BalasI have an alternative technique which uses a simple level of detail calculation. http://tableautim.com/step-line-chart-tableau-quick-tip/
Balas