Forum Discussion
Sort based on Total values in stacked bar chart
- 1 year ago
karthik77700 - so in this case you need to create a DAX measure for the total, this will be:
SUM ( 'Table'[Ret Amount] ) + SUM ( 'Table'[Ced Amount] )Just replace the word Table with your table name. Then add this to the tooltip as I showed in my screenshot.
If I answered your question please mark my post as the solution, it helps others with the same challenge find the answer!
Hey karthik77700 ,
It seems that you're working on a stacked bar chart and need to sort the bars based on the total of two columns (i.e., the sum of the values on the bar). You can achieve this in Power BI by following these steps:
Create a Measure for Total:
Instead of just summing the two columns, you can create a measure that removes the filters from the legend (or any category you're using in the stacked bar chart) to get the total value. Use the following DAX expression:Total Measure = CALCULATE( [Your Measure], REMOVEFILTERS('Table'[ColumnInLegend]) )[Your Measure] would be the measure you're currently using in the visual (for example, a sum of a column).
'Table'[ColumnInLegend] is the column used in the legend or category for your stacked bar chart. This ensures that the total is calculated across all the categories, not just for the ones displayed.
Sort by the Total Measure:
Once you’ve added the Total Measure to the Tooltip, you can use it for sorting your stacked bar chart.Right-click on the axis field in the visual and choose Sort by Total Measure.
If you found this solution helpful, please consider accepting it and giving it a kudos (Like) it’s greatly appreciated and helps others find the solution more easily.
Best Regards,
Nasif Azam