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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
akhaliq7
Post Prodigy
Post Prodigy

Switch statement when multiple conditions are applied

Hi I want to use a switch statement whereby I use two fields for the condition e.g.

 

I want the condition to be:

case 1:

product availability: Y

product stock: 1-10 -> low stock

 

case 2:

product availability: Y

product stock: 11-50 -> Mid Level Stock

 

case 3:

product availability: Y

product stock: 11-50 -> High Level Stock

 

 

1 ACCEPTED SOLUTION
SanketBhagwat
Solution Sage
Solution Sage

Hi @akhaliq7 .

You can create a measure like;
Availability=
var a=SELECTEDVALUE(Table[Product Stock])
var b=SELECTEDVALUE(Table[Product Availibility)
return
SWITCH(
TRUE(),a="1-10" && b="Y","Low stock",
a="11-50" && b="Y" ,"Mid Level stock",
a="50-100" && b="Y" ,"High Level stock").


Let me know if that works.

Thanks,
Sanket


If this post helps, then mark it as 'Accept as Solution' and give it a thumbs up.





View solution in original post

3 REPLIES 3
DimaMD
Solution Sage
Solution Sage

Hi @akhaliq7  try it

 

VAR stok = sum(table[product stok])
return
SWITCH(
    TRUE(),
AND(stok >= 1,stok <= 10), "low stok",
AND(stok >= 11,stok < 50),  "mid stok"
stok >=50,  "high stok")

 

 


__________________________________________

Thank you for your like and decision

__________________________________________

Greetings from Ukraine

To help me grow PayPal: embirddima@gmail.com
SanketBhagwat
Solution Sage
Solution Sage

Hi @akhaliq7 .

You can create a measure like;
Availability=
var a=SELECTEDVALUE(Table[Product Stock])
var b=SELECTEDVALUE(Table[Product Availibility)
return
SWITCH(
TRUE(),a="1-10" && b="Y","Low stock",
a="11-50" && b="Y" ,"Mid Level stock",
a="50-100" && b="Y" ,"High Level stock").


Let me know if that works.

Thanks,
Sanket


If this post helps, then mark it as 'Accept as Solution' and give it a thumbs up.





thanks your solution worked only thing I changed was instead of a="1-10" i did a>=1 && a<= 10 && b="N". 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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