Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi, I have a power bi report using direct query that has a 100% stacked bar chart that displays the volume by users split by category.
The columns are
I would like to sort the bars to display by percentage in descending order but currently it always sorts by the legend. Any ideas how I can force it to sort by % volume. Thanks
Solved! Go to Solution.
Hi @jj304 ,
Since we can't use measure for y-axis, to achieve this sorting effect, I suggest you create a calculated table:
NewTable = ADDCOLUMNS(
'Table',
"AdjustedUser1", IF(
'Table'[Category] = "A",
RANKX(
FILTER('Table', 'Table'[Category] = "A"),
'Table'[Volume],
,
ASC,
DENSE
) & "_" & 'Table'[User]
),
"NewUser1", CALCULATE(
MAX('Table'[AdjustedUser1]),
ALLEXCEPT('Table', 'Table'[User])
)
)
Then use the columns in the new table to create a bar chart.
Best Regards,
Zhu
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Thanks for the replies from parry2k.
Hi @jj304 ,
According to your description, I created simple data.
When sorting this chart, it can only be sorted by one of the X-axis or Y-axis, if at the same time, you need the percentage to show the effect of descending, you can create a new calculated column that meets the descending order of the percentage, and use it as the Y-axis. The steps are as follows:
1. Create calculated columns:
AdjustedUser = IF('Table'[Category]="A",RANKX(FILTER('Table','Table'[Category]="A"),'Table'[Volume],,ASC,Dense)&"_"&'Table'[User])NewUser =
CALCULATE(MAX('Table'[AdjustedUser]),ALLEXCEPT('Table','Table'[User]))
2. Use Newuser as the y-axis and sort by it:
3. Comparison of results:
Best Regards,
Zhu
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous, thanks for your reply. I am using Direct Query for this report so i cannot use this dax in a calculated columns. When i try to use the dax in a measure it forces me to use some form of aggregration for the columns.
Hi @jj304 ,
Since we can't use measure for y-axis, to achieve this sorting effect, I suggest you create a calculated table:
NewTable = ADDCOLUMNS(
'Table',
"AdjustedUser1", IF(
'Table'[Category] = "A",
RANKX(
FILTER('Table', 'Table'[Category] = "A"),
'Table'[Volume],
,
ASC,
DENSE
) & "_" & 'Table'[User]
),
"NewUser1", CALCULATE(
MAX('Table'[AdjustedUser1]),
ALLEXCEPT('Table', 'Table'[User])
)
)
Then use the columns in the new table to create a bar chart.
Best Regards,
Zhu
If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@jj304 check the sort column by clicking the 3 dots on the visual.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
@jj304 on the format pane, under layout, turn reverse order on and that will do it.
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Hi @parry2k, thanks for your reply. The reverse order reverses the ordering of bars but its still displaying by the legend (category)
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 48 | |
| 43 | |
| 39 | |
| 19 | |
| 17 |
| User | Count |
|---|---|
| 68 | |
| 63 | |
| 31 | |
| 30 | |
| 23 |