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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Variables using Switch True

Hi, 

I would like to make variables on sales using the North Wind database. But when trying to use the Var_salg column all of my products are placed in group "D: Over 10000"

Var_salg =
VAR Val =
SUMX(Order_Details;Order_Details[UnitPrice]*Order_Details[Quantity])
Return
SWITCH(TRUE();

 

Val <=1000; "A: 0-1000";
Val <=5000; "B: 1001-5000";
Val <=10000; "C: 5001-10000";
Val >10000; "D: Over 10000")


 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

It works now. 

 

I simply created a SUMX measure for "I alt salg":

Var_salg =
VAR Val =
[I alt salg]
Return
SWITCH(TRUE();
Val <=1000; "A: 0-1000";
Val <=5000; "B: 1001-5000";
Val <=10000; "C: 5001-10000";
Val >10000; "D: Over 10000")

View solution in original post

3 REPLIES 3
v-chuncz-msft
Community Support
Community Support

@Anonymous 

 

It seems that you'll need to add RELATEDTABLE.

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi @v-chuncz-msft 
How do you mean?

Anonymous
Not applicable

It works now. 

 

I simply created a SUMX measure for "I alt salg":

Var_salg =
VAR Val =
[I alt salg]
Return
SWITCH(TRUE();
Val <=1000; "A: 0-1000";
Val <=5000; "B: 1001-5000";
Val <=10000; "C: 5001-10000";
Val >10000; "D: Over 10000")

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors