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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.