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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
v_mark
Helper V
Helper V

Switch Statement for multiple text criteria

I was creating a switch statement for all the states in the US and Group them into per region.  that will be used for a filter

 

I noticed that I have to declare each state in my switch statement. Just like below

State Groups = SWITCH( TRUE(),
sample[State] = "WV" , "CAPITAL",
sample[State] = "DE" , "CAPITAL",
sample[State] = "DC" , "CAPITAL",
sample[State] = "MD" , "CAPITAL",
sample[State] = "VA" , "CAPITAL",

 

and the rest goes on. 

 

Is there a way to combine at least or write an OR statement instead of having 50+ lines? 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@v_mark , I am adding in and Or example , both will work same in this case

 

State Groups = SWITCH( TRUE(),
sample[State] in{ "WV", "DE","DC","MD","VA"} "CAPITAL", // how to use in
sample[State] = "DE" || sample[State] = "DC" || sample[State] = "DE" , "CAPITAL", //how to use OR

"NA" //deafult va;ue
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

2 REPLIES 2
v_mark
Helper V
Helper V

@amitchandak - Thank you works great!

amitchandak
Super User
Super User

@v_mark , I am adding in and Or example , both will work same in this case

 

State Groups = SWITCH( TRUE(),
sample[State] in{ "WV", "DE","DC","MD","VA"} "CAPITAL", // how to use in
sample[State] = "DE" || sample[State] = "DC" || sample[State] = "DE" , "CAPITAL", //how to use OR

"NA" //deafult va;ue
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.