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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
tmorgan93
New Member

Sort hierarchy for 2 different counts on stacked bar chart

Hello,

 

I have a stacked bar chart where I am trying to rank Organization by count of Programs and Count of Applications, so I have 2 columns/colors/counts showing up in each bar. I am able to sort by using the Top N advanced filtering option for the Count of Programs, but some Programs can have multiple applications within them, so 3 organizations could each have 5 Programs, but then Organization 1 could have 5 applications, Organization 2 could have 8, and so on. I would like to be able to also order the organizations by application as a secondary sort. What is the best way to go about this? Most info on sorting that I've found involves doing something in the dataset, but in this situation my columns aren't summarized by count until I add them to the visual.

1 REPLY 1
speedramps
Super User
Super User

Try this

Rank by program and application= 
VAR Myprogram = SELECTEDVALUE(yourtable[program])
VAR Myapplication= SELECTEDVALUE(yourtable[District])
RETURN
RANKX(
    FILTER(ALLSELECTED(yourtable), yourtable[program] = Myprogram && yourtable[District] = MyDistrict),
    CALCULATE(SUM(yourtable[youramount])),
    ,DESC,
    Dense
    )


Please click thumbs up abd also the accept as solution button. Thank you `

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors