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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
PBIn00b
Advocate II
Advocate II

Using SWITCH with OR (or Multple Criteria)

Is there a way to add a second columns criteria to a SWITCH function?

 

In short, I would like to make a calculation if the STORE # = one of a list OR if the beginning of the Coupon = a certain phrase.  The data is in the same table, but different columns.

 

I started with this to calculate based on the store number only.  Now I need to add the coupon name.

Calculation = CALCULATE((SUM('sales_order'[discount_amount])*-1)*.5,SWITCH('sales_order'[store_id],8,TRUE(),37,TRUE(),38,TRUE(),39,TRUE(),44,TRUE(),0))

 

So in excel I would do something like this to find the beginnging text in the coupon. Unforunately I don't know how to add it to DAX as a condition or even if that is the right way.

 

IFERROR(TRIM(LEFT('sales_order'[coupon],FIND("-",'sales_order'[coupon])-1))="COUPON TEXT",0)))

(I know there may be other ways, but hopefully you get the idea)

 

2 ACCEPTED SOLUTIONS
v-sihou-msft
Microsoft Employee
Microsoft Employee

@PBIn00b

 

In SWITCH() function, we can only put single column to apply condition. Since you need another column for applying condition, you have to use nested IF() to achieve your goal.

 

Regards,

View solution in original post

with the switch statement you can use a test for TRUE() as your evaluation criteria; eg: calc=switch(true(), blah=blah && foo=bar, 1, bar=blah || foo=foo, 2, 3)



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


View solution in original post

3 REPLIES 3
CarineB
New Member

The function OR() can be used with the SWITCH() Function like that : OR(<logical1>,<logical2>) 

v-sihou-msft
Microsoft Employee
Microsoft Employee

@PBIn00b

 

In SWITCH() function, we can only put single column to apply condition. Since you need another column for applying condition, you have to use nested IF() to achieve your goal.

 

Regards,

with the switch statement you can use a test for TRUE() as your evaluation criteria; eg: calc=switch(true(), blah=blah && foo=bar, 1, bar=blah || foo=foo, 2, 3)



I hope this helps,
Richard

Did I answer your question? Mark my post as a solution! Kudos Appreciated!

Proud to be a Super User!


Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors