Forum Discussion

JustinDoh1's avatar
JustinDoh1
Icon for Post Prodigy rankPost Prodigy
5 years ago

Multiple IF statements under Return

I am sharing my Pbix file here.

 

I am trying to have multiple IF statements under Retrurn statement.

I was able to possibly have up to 2 options, when I got to 3 options, I am not sure I am doing it right with || (or) statements.

 

The measure is called "Refused 0817_A" in the file.

Basically, the logic is:

If any of 3 conditions is met (OR), the output should be 0, otherwise, output should be vRefused.

 

I am not sure whether applying SWITCH() works under statement like this where we put under RETURN.

That is the main reason that I am trying to clarify as well.

Thanks.

 

8 Replies

  • Tanushree_Kapse's avatar
    Tanushree_Kapse
    Icon for Impactful Individual rankImpactful Individual

    Hi JustinDoh1 ,

     

    Try this measure for return statement:

     

    Return 

    IF(OR(OR(AND(AND (min(Table1[step])= 1,NOT (min(Table1[Consent])= "Refused"), min(Table1[Consentdate])<> blank()), IFAND(AND (max(Table1[step])= 2 ,NOT (max(Table1[Consent])= "Refused"), max(Table1[Consentdate])<> blank()), AND(AND (min(Table1[step])= 1,NOT (min(Table1[Consent])= "Refused"), min(Table1[Consentdate])<> blank())), IF(AND(AND (min(Table1[step])= 1,NOT (min(Table1[Consent])= "Refused")), vimmunization < vconsent)), 0, vrefused)

     

     

    I hope this helps!

     

    Mark this as a solution if I answered your question. Kudos are always appreciated.

    Thanks!

  • Tanushree_Kapse Thanks for help.

    Don't we have to put && or ||  between lines?

    Also, when you mentioned "measure", do you mean, put your suggested code in a separate measure and insert the measure inside the original code? Thanks.

    • Tanushree_Kapse's avatar
      Tanushree_Kapse
      Icon for Impactful Individual rankImpactful Individual

      Hi JustinDoh1 ,

       

      We are putting OR and AND statements instead of them.

       

      Also, put this statements in your Return part of your existing measure.

       

       

      Thanks

      • JustinDoh1's avatar
        JustinDoh1
        Icon for Post Prodigy rankPost Prodigy

        Tanushree_Kapse Thanks for quick reply. While I am still trying to put your code so that there is no error message, I have a quick question. So, in DAX we do not use && or || ? I am looking at other part of code where I used && and ||. 

        BTW, I am trying to apply your code here, but I am not sure I am doing it right.