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
plin924
Frequent Visitor

If Statement applied at a certain aggregated level

Hi,

I need help with DAX.  

 

I have a table that has a varius level of aggregate.  (Region, Office, Sales Person).

 

How do I write the following measures?
1) Aggregate Numerator and Denominator at Office level.

plin924_0-1732039389054.png

2) apply an if statement, also at office level?   
switch(true(),
divide(office level numerator, office level denominator,0)>40%,"Bad"
divide(office level numerator, office level denominator,0)>60%,"Average"
divide(office level numerator, office level denominator0)>80%,"Good"
divide(office level numerator, office level denominator,0)>100%,"Perfect"

)

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @plin924 ,

You can create two measures as below to get it, please find the details in the attachment.

Percent = DIVIDE(SUM('Table'[Numerator]),SUM('Table'[Denominator])) 
Office level = 
VAR _sumofper =
    SUMX ( ALLEXCEPT ( 'Table', 'Table'[Office] ), [Percent] )
RETURN
    SWITCH (
        TRUE (),
        _sumofper > 1, "Perfect",
        _sumofper > 0.8
            && _sumofper <= 1, "Good",
        _sumofper > 0.6
            && _sumofper <= 0.8, "Average",
        _sumofper <= 0.6, "Bad"
    )

vyiruanmsft_1-1732174101360.png

Best Regards

View solution in original post

3 REPLIES 3
Jai-Rathinavel
Super User
Super User

Hi @plin924 , You can write a DAX measure like below

Office Level % =
var result = CALCULATE(DIVIDE(SUM(Table[Numerator]),SUM(Table[Denominator]),0),ALLEXCEPT(Table[Office]))
RETURN
SWITCH(
        TRUE(),
        result <= 0.4, "Bad",
        result > 0.4 && result <= 0.6,"Average",
        result > 0.6 && result <= 0.8,"Good",
        result > 0.8 && result <= 1,"Perfect")

 

Did I answer your question ? If yes, please mark this post as a solution

 

Thanks,

Jai




Did I answer your question? Mark my post as a solution!

Proud to be a Super User!





sorry.. it didn't quite work. I was hoping it will apply criteria first, then sum. It didn't sum properly.

 

Anonymous
Not applicable

Hi @plin924 ,

You can create two measures as below to get it, please find the details in the attachment.

Percent = DIVIDE(SUM('Table'[Numerator]),SUM('Table'[Denominator])) 
Office level = 
VAR _sumofper =
    SUMX ( ALLEXCEPT ( 'Table', 'Table'[Office] ), [Percent] )
RETURN
    SWITCH (
        TRUE (),
        _sumofper > 1, "Perfect",
        _sumofper > 0.8
            && _sumofper <= 1, "Good",
        _sumofper > 0.6
            && _sumofper <= 0.8, "Average",
        _sumofper <= 0.6, "Bad"
    )

vyiruanmsft_1-1732174101360.png

Best Regards

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