How do you sort stacked bar chart by value

Hi @sambhavbhandari -

Currently QS will not sort the Group/Color using a value. Here is a workaround that you can use.

Step 1 - Create a calculated field that will show your stacked group plus what rank the value is.

c_rank:

rank([value DESC],[col2], PRE_AGG)

Step 2 - Concat your rank + your stacked group.

c_sort_col1_string:

concat(tostring({c_rank}),col1)

Step 3 - Change the legend colors so that all stacked groups are the same color.

Step 4 - Hide the legend and create your own legend with a custom visual (if desired)

Result:

3 Likes