Forum Discussion
Sort 100% stacked bar chart for survey
Hi, hope somebody can help?
I have some survey data I'm trying to analyse.
Response to a question is either:
Fairly safe
Fairly unsafe
Neither safe nor unsafe
Very safe
Very unsafe
And the responses are grouped by age (55-64, 65+ etc.) of the respondent.
I've created this 100% stacked bar chart :
I'm trying to sort the chart by 'the Fairly safe %' descending.
I've searched online and followed a suggestion of creating a measure and adding it as a tooltip and then sorting the axis by the tooltip:
Hi Fusilier
If you need to sort the stacked graph by its "slices" you need to create separate measures for every group at the legend like :Fairly safe = CALCULATE(COUNTROWS('Table'),'Table'[answer]="Fairly safe")Fairly unsafe = CALCULATE(COUNTROWS('Table'),'Table'[answer]="Fairly unsafe")Neither safe nor unsafe = CALCULATE(COUNTROWS('Table'),'Table'[answer]="Neither safe nor unsafe")Then you can select by which group you want to sort the graph :
The pbix with the example is attached
P.s It's important to note that stacked graphs are complex to read and not really effective for data visualization. I'm attaching a link to my article on the subject, including an alternative.https://www.madeiradata.com/post/home-experiments-and-stacked-bar-graphs
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly
3 Replies
- Ritaf1983
Super User
Hi Fusilier
If you need to sort the stacked graph by its "slices" you need to create separate measures for every group at the legend like :Fairly safe = CALCULATE(COUNTROWS('Table'),'Table'[answer]="Fairly safe")Fairly unsafe = CALCULATE(COUNTROWS('Table'),'Table'[answer]="Fairly unsafe")Neither safe nor unsafe = CALCULATE(COUNTROWS('Table'),'Table'[answer]="Neither safe nor unsafe")Then you can select by which group you want to sort the graph :
The pbix with the example is attached
P.s It's important to note that stacked graphs are complex to read and not really effective for data visualization. I'm attaching a link to my article on the subject, including an alternative.https://www.madeiradata.com/post/home-experiments-and-stacked-bar-graphs
If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly