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! Learn more

Reply
snow87
Helper I
Helper I

How do you combine ALLEXCEPT and IF statements?

Could someone give me an example of combining allexcept and if?

1 ACCEPTED SOLUTION

Figured out a cludgy way of doing it with multiple columns. Thanks for looking into it.

View solution in original post

5 REPLIES 5
PaulDBrown
Community Champion
Community Champion

What is it you are trying to do?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I have stones that have multiple stages of varying duration, with each stage possibly on a different bus line.

 

stone idstagedurationbus

 

I'm trying to return which bus line the stone spent the largest percentage of it's total duration (summed from all stages).

 

I created columns for

total stone durationPortion of total growth durationHighest portion per bus

and those work (with Highest Portion per Bus giving me the value for the bus in that row.)

 

This is the column formula for Highest Portion per bus:

Highest Portion Per Bus = CALCULATE( SUM (Growth[Portion of Total Growth Duration]), ALLEXCEPT(Growth, Growth[STONE_ID], Growth[Bus]))
 
I'm trying to use that to return a Bus value for each Stone ID.
 
I'm struggling with writing DAX for:
For each stone id, if the highest portion per bus = max(highest portion per bus), return bus
PC2790
Community Champion
Community Champion

With some understanding of your requirement, I suppose this will work:

FIRSTNONBLANK(TOPN(1,VALUES(Growth[Bus]),[YourMeasure/Calculatedcolumn]),1)

Figured out a cludgy way of doing it with multiple columns. Thanks for looking into it.

This gives me the same bus for all the stones. How do return the result for each stone id?

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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