Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code FABINSIDER for a $400 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi All,
I have a measure which calculates the percentage of missing data in a column.
I have added this measure to the bar chart below.
X-Axis - Attribute
Y_Axis - Measure
Legend - Region
What I want is to sort the bars within the regions but I haven't been able to do it
My Measure (Note the measure does perform some filters in the calcs that I left out, That's why it looks repetitive)
Missing Data % =
VAR TotalRows = COUNTROWS('Data')
RETURN
SWITCH(
TRUE(),
SELECTEDVALUE('Data'[Attribute]) = "Attribute 1",
DIVIDE(
CALCULATE(COUNTROWS('Data'), 'Data'[Value] = "Attribute 2"),
TotalRows),
SELECTEDVALUE('Data'[Attribute]) = "Attribute 2",
DIVIDE(
CALCULATE(COUNTROWS('Data'), 'Data'[Value] = "Attribute 2"),
TotalRows),
SELECTEDVALUE('Data'[Attribute]) = "Attribute 3",
DIVIDE(
CALCULATE(COUNTROWS('Data'), 'Data'[Value] = "No Value"),
TotalRows),
SELECTEDVALUE('Data'[Attribute]) = "Attribute 4",
CALCULATE(DIVIDE(
CALCULATE(COUNTROWS('Data'), 'Data'[Value] = "No Value"),
TotalRows2)),
SELECTEDVALUE('Data'[Attribute]) = "Attribute 5",
DIVIDE(
CALCULATE(COUNTROWS('Data'), 'Data'[Value] = "No Value"),
TotalRows),
0 // Default return value if none of the conditions are met
)
Can someone tell me how I can sort the bars withint each region?, I don't want to create a calculated table either as I have several filters on the page that need to be functional
Hi @obriaincian
Sorting the legends by the value within a specific category currently isn't supported. There are workarounds but they aren't perefect. In the screenshot below, Geo column is ranked by Total Revenue. The ranks are then materialized using a disconnected table and then a column from that disconnected table is used in the visual.
The second chart uses small multiples.
Please see the attached sample pbix.
Hello @obriaincian
If you dont have any specific sort criteria the go to the 3 dot of the visual and go to sort the legend option. Below screenshot
if you have any specific sorting condition then go to Power query or your data source and add a sorting column. Use that column for region sorting. Just like below screenshot
Hope it helps
Regards
sanalytics
@sanalytics you are sorting by region, this is not what I want. I want to sort by the bars within each of the regions
Hi @obriaincian ,
Power BI does not allow you to re-sort each region’s bars independently when they share the same X-axis. The chart treats the Attribute field as one set of categories and applies a single sort rule across them (alphabetical or by a single measure). A typical workaround is to use small multiples, where each region becomes its own mini-chart and you can independently sort by “Missing Data %.” For example, you could add a rank measure like “Rank Attribute = RANKX(ALL('Data'[Attribute]), [Missing Data %], [Missing Data %], DESC)” and then sort each small multiple by this rank measure. Another option is to create a separate visual for each region, then filter the chart to that region and sort by your measure. If you need one single global order (rather than different orders per region), you can create a custom column to specify a sort index, then use “Sort by Column” on that column to define the order of your attributes.
Best regards,
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Check out the February 2025 Power BI update to learn about new features.
User | Count |
---|---|
83 | |
79 | |
53 | |
39 | |
37 |
User | Count |
---|---|
104 | |
85 | |
47 | |
43 | |
42 |