Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Mayu
Frequent Visitor

Bar chart sort by volume but "others" at the bottom

I am looking for a way to sort a bar chart based on the volume but "Others" keep at the bottom. 

It seems like I can only sort by the volume or category name in alphabetical order. Is there a way?

Mayu_0-1702333898166.png

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @Mayu 

 

You can try the following methods.
Example data:

vzhangti_0-1702628871541.png

Sum Measure = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Category],'Table'[record_type_name__c]))
Sort1 = 
Var _Rank=RANKX(FILTER(ALL('Table'),[Category]<>"Other"),[Sum Measure],,DESC)
Var _Maxcount=CALCULATE(DISTINCTCOUNT('Table'[Category]),ALL('Table'))
Return
IF(SELECTEDVALUE('Table'[Category])<>"Other",_Rank,_Maxcount)
Sort2 = 
Var _Rank=RANKX(FILTER(ALL('Table'),[Category]<>"Other"&&[record_type_name__c]="Complaint"),[Sum Measure],,DESC)
Var _Maxcount=CALCULATE(DISTINCTCOUNT('Table'[Category]),FILTER(ALL('Table'),[record_type_name__c]="Complaint"))
Return
IF(SELECTEDVALUE('Table'[record_type_name__c])<>"Complaint",BLANK(),IF(SELECTEDVALUE('Table'[Category])<>"Other",_Rank,_Maxcount))

vzhangti_1-1702628926574.png

Which is your desired sorting result? If this does not solve your problem, please provide more information.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
Mayu
Frequent Visitor

Thank you, v-zhangti.

I needed to tweak slightly because rankx was not bringing the value I was expecting but I was able to make it work! Thank you for the help! Greatly appreciated!!

Sort 2 =
Var _Rank=RANKX(FILTER(ALL(v_salesforce_feedback[Complaint Category],v_salesforce_feedback[record_type_name__c]),[record_type_name__c] = "Complaint" && [Complaint Category]<>"Other"),[Ttl Complaint # by Category],,DESC)
Var _Maxcount=CALCULATE(distinctCOUNT(v_salesforce_feedback[Complaint Category]), filter(all(v_salesforce_feedback),[record_type_name__c] = "Complaint"))
RETURN
IF(SELECTEDVALUE(v_salesforce_feedback[record_type_name__c])<>"Complaint",blank(), if(SELECTEDVALUE(v_salesforce_feedback[Complaint Category]) <> "Other",_Rank,_Maxcount))

 

Mayu

v-zhangti
Community Support
Community Support

Hi, @Mayu 

 

You can try the following methods.

Example data:

vzhangti_0-1702455150138.png

Measure:

Sum Measure = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Category]))
Sort = 
Var _Rank=RANKX(FILTER(ALL('Table'),[Category]<>"Other"),[Sum Measure],,DESC)
Var _Maxcount=CALCULATE(DISTINCTCOUNT('Table'[Category]),ALL('Table'))
Return
IF(SELECTEDVALUE('Table'[Category])<>"Other",_Rank,_Maxcount)

vzhangti_1-1702455217104.png

vzhangti_2-1702455279440.png

Is this the result you expect? Please see the attached document.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you so much, Charlotte!

I was able to get up to here but the sorting number was not as I expected. I need to filter the value by record_type_name__c = "Complaint".  Could you help me where I can insert the filiter logic? 

Mayu_0-1702491390142.png

Thank you!

I need to filter record name 

v-zhangti
Community Support
Community Support

Hi, @Mayu 

 

Can you give an example of what the relationship between Category and record name looks like?

 

Best Regards

Thank you, v-zhangti

 

record_type_name is the highest level that the inquery is sorted out like below.  Of those, complaint category are designed to get more details so there are complaint category and more. 

Mayu_0-1702582749731.png

Complaint category is one below level from record_type_name. I want to assign the sorting number within the Complaint category (Complaint Category = if(v_salesforce_feedback[complaint_category__c] = "" && v_salesforce_feedback[record_type_name__c] = "Complaint", "Other",
if(v_salesforce_feedback[record_type_name__c] = "Complaint" && v_salesforce_feedback[complaint_category__c] <> "", v_salesforce_feedback[complaint_category__c] , v_salesforce_feedback[record_type_name__c])).

 

I tried the workaround to enter -99999 and added to Tooltips. it works but -99999 is showing up and it might confuse the dashboard users. So if I can make the Sorting function works, that would be the best solution for us. 

Mayu_1-1702582994100.png

 

Thank you for your help!

 

v-zhangti
Community Support
Community Support

Hi, @Mayu 

 

You can try the following methods.
Example data:

vzhangti_0-1702628871541.png

Sum Measure = CALCULATE(SUM('Table'[Value]),ALLEXCEPT('Table','Table'[Category],'Table'[record_type_name__c]))
Sort1 = 
Var _Rank=RANKX(FILTER(ALL('Table'),[Category]<>"Other"),[Sum Measure],,DESC)
Var _Maxcount=CALCULATE(DISTINCTCOUNT('Table'[Category]),ALL('Table'))
Return
IF(SELECTEDVALUE('Table'[Category])<>"Other",_Rank,_Maxcount)
Sort2 = 
Var _Rank=RANKX(FILTER(ALL('Table'),[Category]<>"Other"&&[record_type_name__c]="Complaint"),[Sum Measure],,DESC)
Var _Maxcount=CALCULATE(DISTINCTCOUNT('Table'[Category]),FILTER(ALL('Table'),[record_type_name__c]="Complaint"))
Return
IF(SELECTEDVALUE('Table'[record_type_name__c])<>"Complaint",BLANK(),IF(SELECTEDVALUE('Table'[Category])<>"Other",_Rank,_Maxcount))

vzhangti_1-1702628926574.png

Which is your desired sorting result? If this does not solve your problem, please provide more information.

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

vicky_
Super User
Super User

There's two work-arounds that I found:
The first one is from this forum thread - https://community.fabric.microsoft.com/t5/Desktop/Sort-Stacked-Bar-chart/m-p/3418133 where you basically put a custom sort in your tooltips, and sort by that.

Or you'll need to create a cusom sort measure, which is explained at the end of this article: https://www.sqlbi.com/articles/filtering-the-top-products-alongside-the-other-products-in-power-bi/

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.