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
DHB
Helper V
Helper V

Sorting a Stacked Bar Chart with Switch Measures

I have a stacked bar chart which displays data using two different measures (Head Count and EFTSL) and I can flip from one to the other using a switch in a Chiclet slicer.

 

DHB_0-1661411088211.png

 

In the chart I use this measure in the X-axis;

 

EFTSL/HC = IF (

    HASONEVALUE ( 'SWITCH_Measures'[SWITCH Measures] ),

    SWITCH (

        FIRSTNONBLANK ( 'SWITCH_Measures'[SWITCH Measures], 1 ),

        "Head Count",

            DISTINCTCOUNT( 'F - Enrolment Fact'[Person Identifier] ),

        "EFTSL", SUM ( 'F - Enrolment Fact'[EFTSL] ),

        BLANK ()

    ),

    BLANK ()

)

 

Now the chart is supposed to sort the bars by the total value of each bar, which it will do fine if I don’t put a legend in, but I need to use a legend and then it gets a bit confused somewhere.

DHB_1-1661411088217.png

 

Do you have any suggestions as to anything I could try?

 

Thank you!

 

DHB

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@DHB , Have you tried Switch using field parameters? And check if that suites to your requirements better

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@DHB , Have you tried Switch using field parameters? And check if that suites to your requirements better

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

In the end using Count instead of DistinctCount fixed it for me.  I think the distinct count was a problem once I threw a legend into the chart.  Without the legend either type of count was fine.  Thanks for the new method of switching - it's much easier than what I had been doing before.  I'll definitely be using that in future.

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
Top Kudoed Authors