Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

SWITCH TRUE with multiple conditions

Hi,

 

Would someone be able to tell me why my SWITCH(TRUE() function with multiple conditions is returing wrong anwers? Just look at row 2 in of the attached screenshot - it should return "Group 4", instead it's returning "Group 2".

 

Thank you for your help,

Giac

  • Anonymous , use the brackets (condition || condition) && (condition || condition).

    If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

2 Replies

  • ERD's avatar
    ERD
    Icon for Community Champion rankCommunity Champion

    Anonymous , use the brackets (condition || condition) && (condition || condition).

    If this post helps, then please consider Accept it as the solution ✔️to help the other members find it more quickly.

    • AlexisOlson's avatar
      AlexisOlson
      Icon for Super User rankSuper User

      Yep, in logical statements && comes first in order of operations before ||, like multiplication comes before addition.

       

      A && B || C = ( A && B ) || C just like A * B + C = ( A * B ) + C.