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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
karkar
Helper III
Helper III

MULTIPLE IF CONDITIONS

Hello,

 

Can anyone help me with the DAX for this?

 

 

1 ACCEPTED SOLUTION

Hi @karkar,

In excel, we calculate based on cell, while in Power BI, we calculate the value based on column. The difference for DAX and excel function is: there are only logical conditions in AND in DAX. In excel, you can more than two conditions in AND like: AND(logical1, [logical2], ...). I create it in excel and get expected result.

In excel, AND(A8= "Not Hispanic or Latino Origin",B8<>"Unavailable",B8<>"Declined") is equals to AND(A8= "Not Hispanic or Latino Origin",AND(B8<>"Unavailable",B8<>"Declined"))

The results of using AND and OR in the red part are different. I confused it before, so I edit my last reply. Thanks for understanding. Now I test it in BI and Excel.  

=IF(OR(A8="Hispanic or Latino Origin Unknown",A8="Declined - patient is unwilling to respond"),"Unknown",IF(A8="Hispanic or Latino Origin", "Hispanic",IF(AND(A8= "Not Hispanic or Latino Origin",B8<>"Unavailable",B8<>"Declined"),B8,"Unknown")))

=IF(OR(A8="Hispanic or Latino Origin Unknown",A8="Declined - patient is unwilling to respond"),"Unknown",IF(A8="Hispanic or Latino Origin", "Hispanic",IF(AND(A8= "Not Hispanic or Latino Origin",OR(B8<>"Unavailable",B8<>"Declined")),B8,"Unknown")))



Using ANDUsing ANDUsing ORUsing OR
Best Regards,
Angelia

View solution in original post

10 REPLIES 10
bsas
Post Patron
Post Patron

Hi,

 

From your explanation I didn't understand what you want to receive in the end. Could you please provide more details.

 

Please try to use formula below:

 

Devired race_test = IF(OR(ETHNICITY = "Hispanic or Latino Origin Unknown","Declined - patient is unwilling to respond"), "Unknown",IF(ETHNICITY = "Hispanic or Latino Origin", "Hispanic",IF(AND(ETHNICITY = "Not Hispanic or Latino Origin", RACE <> "Unavailable"), RACE, "Unknown")))

Hello bsas,

 

Thansk for the help.This has gotten me very close to what i need.

I have added one more row  and how do i add Declined to the existing formulea????

@karkar

 

Devired race_test = IF(OR(ETHNICITY = "Hispanic or Latino Origin Unknown","Declined - patient is unwilling to respond"), "Unknown",IF(ETHNICITY = "Hispanic or Latino Origin", "Hispanic",IF(AND(ETHNICITY = "Not Hispanic or Latino Origin", OR(RACE <> "Unavailable", RACE <> "Declined")), RACE, "Unknown")))

Hi @karkar,

Please create a calculated column using the formula.

DERIVED RACE =
IF (
    OR (
        Table1[ETHNICITY] = "Hispanic or Latino Origin Unknown",
        Table1[ETHNICITY] = "Declined - patient is unwilling to respond"
    ),
    "Unknown",
    IF (
        Table1[ETHNICITY] = "Hispanic or Latino Origin",
        "Hispanic",
        IF (
            AND (
                Table1[ETHNICITY] = "Not Hispanic or Latino Origin",
                AND ( Table1[RACE] <> "Unavailable", Table1[RACE] <> "Declined" )
            ),
            Table1[RACE],
            "Unknown"
        )
    )
)


You will get expected result shown in the following screenshot.

1.PNG

Best Regards,
Angelia

Thansk v-Huizhn,

 

 

Hi @karkar,


As I tested,  when you use the OR in red part. The result both of the two rows("Unavailable" and "Declined" rows) is equals to result of any of the rows.

1.PNG

The result is different from using AND.

Best Regards,
Angelia

Thanks Angelia,

 

I tested first in Excel and the Unavialble and Declined are not being converted to UNKNOWN for "Not Hispanic or Latino Origin".

Do you think we have to do anything different in Excel?

 

Thank you

Hi @karkar,

In excel, we calculate based on cell, while in Power BI, we calculate the value based on column. The difference for DAX and excel function is: there are only logical conditions in AND in DAX. In excel, you can more than two conditions in AND like: AND(logical1, [logical2], ...). I create it in excel and get expected result.

In excel, AND(A8= "Not Hispanic or Latino Origin",B8<>"Unavailable",B8<>"Declined") is equals to AND(A8= "Not Hispanic or Latino Origin",AND(B8<>"Unavailable",B8<>"Declined"))

The results of using AND and OR in the red part are different. I confused it before, so I edit my last reply. Thanks for understanding. Now I test it in BI and Excel.  

=IF(OR(A8="Hispanic or Latino Origin Unknown",A8="Declined - patient is unwilling to respond"),"Unknown",IF(A8="Hispanic or Latino Origin", "Hispanic",IF(AND(A8= "Not Hispanic or Latino Origin",B8<>"Unavailable",B8<>"Declined"),B8,"Unknown")))

=IF(OR(A8="Hispanic or Latino Origin Unknown",A8="Declined - patient is unwilling to respond"),"Unknown",IF(A8="Hispanic or Latino Origin", "Hispanic",IF(AND(A8= "Not Hispanic or Latino Origin",OR(B8<>"Unavailable",B8<>"Declined")),B8,"Unknown")))



Using ANDUsing ANDUsing ORUsing OR
Best Regards,
Angelia

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 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.