Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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?
Solved! Go to Solution.
@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
)
@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
)