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!
I havent created any measure they are just two direct columns(Ret Amount and Ced amount) used in X axis and there is no legends added as well.Just enabled legends in format field .how to write expression for this
- mark_endicott1 year agoSuper User
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!
- Nasif_Azam1 year agoSuper User
Hey karthik77700 ,
To address the issue of sorting the stacked bar chart based on the total of the two columns (Ret Amount and Ced Amount). Here's the upadated solution:
Create a Measure for Total: Since there are no measures currently, you can create a new measure that sums the two columns (Ret Amount and Ced Amount).
TotalAmount = SUM('YourTable'[Ret Amount]) + SUM('YourTable'[Ced Amount])Sort by the Total Measure: Once you've created this measure, use it to sort the categories in your stacked bar chart. In Power BI, you can:
Select your visual.
Go to the Fields pane.
Select the axis (X-axis in your case).
Under Sort by, select the newly created TotalAmount 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- v-aatheeque1 year agoCommunity Support
Hi karthik77700 ,
I wanted to follow up on your requirement regarding sorting the stacked bar chart based on the total values of the two columns.As mentioned by community member, the solution provided should help you achieve the desired sorting of your data (e.g., 110 bn, 50 bn, 20 bn, 14 bn, 7 bn) based on the total amounts.If this solution has resolved your issue, please consider marking it as the Accepted Answer. This not only helps acknowledge the effort of the contributor but also assists others in the community who may have similar questions.
If you still have any questions or need further assistance, please feel free to reach out. We’re here to help!
Thank you for being an active part of our community!
Best regards,
atheeq.