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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

IF with multiple conditions

Hi, I have this tree of conditions: 

semaforo.png

 

 

 

 

 

 

 

 

 

 

 

 

and I traduce it to Power BI using the fields:

 

TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="CLS" && TotalData[Total]<100 && TotalData[Status]="NO" ,"Green",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="CLS" && TotalData[Total]>100 && TotalData[Status]="NO" ,"Green",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="CLS" && TotalData[Total]<100 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="CLS" && TotalData[Total]>100 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="REL" && TotalData[Total]<100 && TotalData[Status]="NO" ,"Yellow",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="REL" && TotalData[Total]>100 && TotalData[Status]="NO" ,"Red",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="REL" && TotalData[Total]<100 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY19" && TotalData[WBS Status]="REL" && TotalData[Total]>100 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="CLS" && TotalData[Total]<10 && TotalData[Status]="NO" ,"Green",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="CLS" && TotalData[Total]>10 && TotalData[Status]="NO" ,"Red",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="CLS" && TotalData[Total]<10 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="CLS" && TotalData[Total]>10 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="REL" && TotalData[Total]<10 && TotalData[Status]="NO" ,"Yellow",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="REL" && TotalData[Total]>10 && TotalData[Status]="NO" ,"Red",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="REL" && TotalData[Total]<10 && TotalData[Status]="YES" ,"Green",
TotalData[Fiscal Year]="FY20" && TotalData[WBS Status]="REL" && TotalData[Total]>10 && TotalData[Status]="YES" ,"Green",

 

 

Which is the best practice to make the IF condition and generate a calculated column?

 

Thanks!

1 ACCEPTED SOLUTION
Tad17
Solution Sage
Solution Sage

Hey @Anonymous 

 

You can use the AND and OR functions or even embed IF statements in Power BI just like you can in excel if you have an if function with multiple criteria.

 

AND: https://docs.microsoft.com/en-us/dax/and-function-dax

OR: https://docs.microsoft.com/en-us/dax/or-function-dax

Depending on your situation you may also want to consider the SWITCH function: https://docs.microsoft.com/en-us/dax/switch-function-dax

 

Examples: https://community.powerbi.com/t5/Desktop/DAX-Measure-with-Nested-IF-Statements/td-p/113358

https://stackoverflow.com/questions/40254578/multiple-if-statements-in-dax

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

Please try this:

Scorecard Status =
IF (
    OR ( 'TotalData'[Fiscal Year] = "FY19", 'TotalData'[Fiscal Year] = "FY20" )
        && 'TotalData'[WBS Status] = "REL"
        && 'TotalData'[Total] < 100
        && 'TotalData'[Status] = "NO",
    "Red",
    (
        IF (
            OR ( 'TotalData'[Fiscal Year] = "FY19", 'TotalData'[Fiscal Year] = "FY20" )
                && OR ( 'TotalData'[WBS Status] = "CLS", 'TotalData'[WBS Status] = "REL" )
                && 'TotalData'[Total] > 100
                && 'TotalData'[Status] = "NO",
            "Yellow",
            "Green"
        )
    )
)

Best Regards

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tad17
Solution Sage
Solution Sage

Hey @Anonymous 

 

You can use the AND and OR functions or even embed IF statements in Power BI just like you can in excel if you have an if function with multiple criteria.

 

AND: https://docs.microsoft.com/en-us/dax/and-function-dax

OR: https://docs.microsoft.com/en-us/dax/or-function-dax

Depending on your situation you may also want to consider the SWITCH function: https://docs.microsoft.com/en-us/dax/switch-function-dax

 

Examples: https://community.powerbi.com/t5/Desktop/DAX-Measure-with-Nested-IF-Statements/td-p/113358

https://stackoverflow.com/questions/40254578/multiple-if-statements-in-dax

 

If this helps please kudo.

If this solves your problem please accept it as a solution.

Anonymous
Not applicable

Thanks! with SWITCH function is working, I just validate it.

🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.