Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
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 everyone,
I have a stacked graph and it is made by a field parameter, however, I can't get the legend to be completely ordered by the rank, do you know how can I sort the legend of the graph?
Thank you!!
Solved! Go to Solution.
Hi, @ChristianCaz
If you want to customize the sort order of the legend, then you can create a calculated column and use this column to sort. Here's a reference:
I have the following chart, the default sort is A, B, C:
I created a calculated column with a custom order using the following DAX:
sort column = SWITCH('Table'[Type],
"A",3,
"B",1,
"C",2
)
I copied the Type column with the following DAX:
Sort the Type copy columns according to the following image:
Put the Type copy column in the legend of the chart:
You can use your rank column to sort your legend columns. Keep in mind, however, that a legend corresponds to a unique ranking. In my example, I have two rows Type=A, both of which rank 3.
If there are two different rankings corresponding to legend A, an error will be reported.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
I know this question is a year old now. But the accepted solution is NOT a solution.
The OP ask how they do this on a Field Parameter (FP) - the solution given does not work when using a field parameter. You cannot use calc columns in a legend where an FP has been used on the Y-Axis. As of Oct-2025 there is still no solution to this.
Hi, @ChristianCaz
If you want to customize the sort order of the legend, then you can create a calculated column and use this column to sort. Here's a reference:
I have the following chart, the default sort is A, B, C:
I created a calculated column with a custom order using the following DAX:
sort column = SWITCH('Table'[Type],
"A",3,
"B",1,
"C",2
)
I copied the Type column with the following DAX:
Sort the Type copy columns according to the following image:
Put the Type copy column in the legend of the chart:
You can use your rank column to sort your legend columns. Keep in mind, however, that a legend corresponds to a unique ranking. In my example, I have two rows Type=A, both of which rank 3.
If there are two different rankings corresponding to legend A, an error will be reported.
How to Get Your Question Answered Quickly
If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .
Best Regards
Jianpeng Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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 |
|---|---|
| 53 | |
| 45 | |
| 44 | |
| 20 | |
| 19 |
| User | Count |
|---|---|
| 73 | |
| 71 | |
| 34 | |
| 33 | |
| 31 |