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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Multiple IF and Conditional Formating

Hi

I have this DAX

SUM(M_KPI[Points]) = dynamic number and keep changing

"discount" and "cashback" = categories

"South City" and  "North City" = zone

KPI_Points =
IF((SUM(SALES[Points] ) > SUM(M_KPI[Points]) && VALUES (SALES [TYPE]) = "discount" && VALUES (Sales [Zone] )= "South City","Red","Black"),

     IF(SUM(SALES[Points] ) > SUM(M_KPI[Points]) && VALUES (SALES [TYPE]) = "cashback" && VALUES (Sales [Zone] )= "North City","Red","Black"))

 

 

but the result gave me an error

is there anything wrong?

 

 

 

1 ACCEPTED SOLUTION
v-luwang-msft
Community Support
Community Support

Hi @Anonymous 

You cold try  the following measure:

KPI_Points =
IF (
    SUM ( SALES[Points] ) > SUM ( M_KPI[Points] )
        && (
             (
                VALUES ( SALES[TYPE] ) = "discount"
                    && VALUES ( Sales[Zone] ) = "South City"
            )
                || (
                    VALUES ( SALES[TYPE] ) = "cashback"
                        && VALUES ( Sales[Zone] )
                ) = "North City"
        ),
    "Red",
    "Black"
)

 

If it still could not work,could pls provide your pbix file ? Remember to remove the confidential information.

 

 

 

Best Regard

Lucien Wang

View solution in original post

5 REPLIES 5
v-luwang-msft
Community Support
Community Support

Hi @Anonymous 

You cold try  the following measure:

KPI_Points =
IF (
    SUM ( SALES[Points] ) > SUM ( M_KPI[Points] )
        && (
             (
                VALUES ( SALES[TYPE] ) = "discount"
                    && VALUES ( Sales[Zone] ) = "South City"
            )
                || (
                    VALUES ( SALES[TYPE] ) = "cashback"
                        && VALUES ( Sales[Zone] )
                ) = "North City"
        ),
    "Red",
    "Black"
)

 

If it still could not work,could pls provide your pbix file ? Remember to remove the confidential information.

 

 

 

Best Regard

Lucien Wang

Anonymous
Not applicable

@v-luwang-msft 

Thank I tried this and it's work, many thank 😄

I have question-related IF with AVERAGE, I used this DAX logic but it doesn't work

May you take look it my DAX is wrong ?

https://community.powerbi.com/t5/Desktop/Different-average-based-on-filter/m-p/1680012#M669449 

Hi  @Anonymous ,

I click your link and find your cace about Different average based on filter   has been taken over by other engineer,he will follow your questions.thanks!

 

Best regard

Lucien Wang

Anonymous
Not applicable

@v-luwang-msftcould you help me because I think your solution more closely match with I am looking for

amitchandak
Super User
Super User

@Anonymous , Try a measure like

 

KPI_Points =
Switch( true() ,
SUM(SALES[Points] ) > SUM(M_KPI[Points]) && max (SALES [TYPE]) = "discount" && Max (Sales [Zone] )= "South City","Red",
SUM(SALES[Points] ) > SUM(M_KPI[Points]) && max (SALES [TYPE]) = "cashback" && Max (Sales [Zone] )= "North City","Red"
,"Black")

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.