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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors