Tableau Blog Reality check for 2015
Onto the Tableau stuff
Many a time I have seen someone build a perfectly nice bar chart, only to have it spoiled by turning on grand totals and having the value of the total skew the rest of the chart. Hell, I have done this myself plenty of times!! Up until recently, I haven't ever given this a second thought and said to myself, "Well if that is how Tableau wants it, then I guess that's what I've got!" Anyone looking at getting into Tableau, or anyone who is fully immersed into Tableau, should never accept what is first given. There is always a solution!
A simple categorical bar chart with grand totals turned off
Here is what happens when we show column grand totals... I'm almost certain this isn't how most would want to display their data.
Calculated field - Sales for Bars
Tableau's SIZE() function does a simple task, it counts the rows in a window. By saying "IF SIZE() = 1 THEN 0" we are simply overriding the Sales field to a 0 when there is only one row in the window.. see where I am going with this? Turning on totals creates a separate window in your view that only has one row. We can provide actual sales for Category but the totals will now be set to zero and will not create a bar that is going to skew our entire chart.
So what now? We have created a calculated field, but I'm still not sure what to do with it. The final solution is simple and can be done in just a few drag and drop actions.
- Replace SUM(Sales) with our calculated field "Sales for Bars" on the columns shelf
- Replace SUM(Sales) with our calculated field "Sales for Bars" for color on the marks card
- Add SUM(Sales) for Label on the marks card