Forum Discussion

karkar's avatar
karkar
Helper III
8 years ago
Solved

MULTIPLE IF CONDITIONS

Hello,

 

Can anyone help me with the DAX for this?

 

 

  • 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 OR
    Best Regards,
    Angelia

10 Replies

  • bsas's avatar
    bsas
    Post Patron

    Hi,

     

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

      • bsas's avatar
        bsas
        Post Patron

        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")))