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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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