Forum Discussion

unclejemima's avatar
unclejemima
Post Patron
8 years ago
Solved

Another IF AND statement question with more than 2 variables :-)

I've got this exact senario what I would typicall use a "If(OR..." statement, but I can't because I can only do 2 arguments...I think I need to use SWITCH but I'm not sure.  Can someone give me the DAX formula for the following...

 

If trandata[account] number is between 6001-6098, or 7030, 7926 or 9071 then retreive the values from trandata[amount]

 

Please and thank you!!!

 

 

  • unclejemima

     

    Hi, lets try with this calculated column:

     

    M =
    IF (
    Trandata[Account] >= 6001
    && Trandata[Account] <= 6098
    || Trandata[Account] = 7030
    || Trandata[Account] = 7926
    || Trandata[Account] = 9071;
    Trandata[Amount]
    )

     

     

    Regards

     

    Victor

7 Replies

  • Vvelarde's avatar
    Vvelarde
    Community Champion

    unclejemima

     

    Hi, lets try with this calculated column:

     

    M =
    IF (
    Trandata[Account] >= 6001
    && Trandata[Account] <= 6098
    || Trandata[Account] = 7030
    || Trandata[Account] = 7926
    || Trandata[Account] = 9071;
    Trandata[Amount]
    )

     

     

    Regards

     

    Victor

    • Vvelarde's avatar
      Vvelarde
      Community Champion

      unclejemima

       

      A shorter version will be:

       

      M =
      IF (
          Trandata[Account] >= 6001
              && Trandata[Account] <= 6098
              || Trandata[Account] IN { 7030; 7926; 9071 };
          Trandata[Amount]
      )

      Regards

       

      Victor

      • unclejemima's avatar
        unclejemima
        Post Patron

        Thanks Vvelarde for the super quick reply!!

         

        I tried the both options...but getting an error

         

        The syntax for ';' is incorrect. (DAX(IF ( Trandata[Account] >= 6001 && Trandata[Account] <= 6098 || Trandata[Account] IN { 7030; 7926; 9071 }; Trandata[amount]))).

         

        Do I have something wrong?

         

        I pasted your exact DAX in.