Sorting a stacked bar chart based on totals

Stacked bar charts are tricky to sort because we need to sort on the total of the entire bars instead of individual subsets.

For example we have a stacked bar chart with various calculated measures like the following:

 count(case when [region] in ('Atlantic') then 1 else null end)

And if you simply sort on one of these measure you don’t get sort on the entire bar total but instead only for the bar making up that portion of the total as shown here:

One solution is to use the tooltips shelf along with a combined calculated measure across all the measures.

  1. Calculated column for the Total

    count(case when [region] in ('Ontario') then 1 else null end)
     +count(case when [region] in ('Atlantic') then 1 else null end)
     +count(case when [region] in ('West') then 1 else null end)
    
  2. And place this in the Tooltips shelf and apply the sort to this shelf element