Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Earl40
Helper I
Helper I

Need help with my custom column switch statement based on multiple criteria

Hello,

 

Im trying to create a custom column that populates a certain value based on multiple criteria (values in other columns). I want it to populate the word "New Case" if the "status column"  doesnt equal "Return" AND the value column equals HIGH and  the state  is not one of 5 states. I tried the formula below and it isnt working. any help would be appreciated

 

Switch(

  TREU(),

                Table name[Status column]<>"Return" && Table name[value column] = " HIGH" && Table name[Status column] ="NY" || Table name[Status column] ="CA" || Table name[Status column] ="NJ" || Table name[Status column] ="MD" || Table name[Status column] ="TX","Normal","New Case")

 

 

1 ACCEPTED SOLUTION
vicky_
Super User
Super User

IF( Table name[Status column]<>"Return" && Table name[value column] = " HIGH" && NOT(Table name[Status column] in {"NY", "CA", "NJ", "MD", "TX"}) ,"Normal","New Case")

OR 

IF(Table name[Status column]<>"Return" && Table name[value column] = " HIGH" && (Table name[Status column] ="NY" || Table name[Status column] ="CA" || Table name[Status column] ="NJ" || Table name[Status column] ="MD" || Table name[Status column] ="TX"),"Normal","New Case")

No need for the switch statement if there's only 2 outcomes.

You can rewrite the Status parts with the in operator to improve readability - read more here: https://www.sqlbi.com/articles/the-in-operator-in-dax/

Or just surround the whole thing with a brackets so that they are evaluated as a group

View solution in original post

1 REPLY 1
vicky_
Super User
Super User

IF( Table name[Status column]<>"Return" && Table name[value column] = " HIGH" && NOT(Table name[Status column] in {"NY", "CA", "NJ", "MD", "TX"}) ,"Normal","New Case")

OR 

IF(Table name[Status column]<>"Return" && Table name[value column] = " HIGH" && (Table name[Status column] ="NY" || Table name[Status column] ="CA" || Table name[Status column] ="NJ" || Table name[Status column] ="MD" || Table name[Status column] ="TX"),"Normal","New Case")

No need for the switch statement if there's only 2 outcomes.

You can rewrite the Status parts with the in operator to improve readability - read more here: https://www.sqlbi.com/articles/the-in-operator-in-dax/

Or just surround the whole thing with a brackets so that they are evaluated as a group

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.