cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Fizzy_Mojito
Helper I
Helper I

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,

GiacWrong outcome.png

1 ACCEPTED SOLUTION
ERD
Super User
Super User

@Fizzy_Mojito , 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.

View solution in original post

2 REPLIES 2
ERD
Super User
Super User

@Fizzy_Mojito , 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.

View solution in original post

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.

Helpful resources

Announcements
Power BI December 2021 Update_carousel 768x460.jpg

Check it Out!

Click here to read more about the December 2021 Updates!

Jan 2022 Dev Camp 768x460 copy.png

Power BI Dev Camp- January 27th, 2022

Mark your calendars and join us for our next Power BI Dev Camp!

UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Top Solution Authors
Top Kudoed Authors