Forum Discussion
heathernicole
Continued Contributor
10 years agoSWITCH statement in DAX using a "between this value and this value" as a filter?
VERY new to DAX - I think my issue is I haven't nailed down how to ask the right question yet - which hinders research for an answer: Trying to create an IF (or a Switch) statement If "this v...
- 10 years ago
The SWITCH statement allows comparisons with constants only. You need to use an IF statement. For a calculated column, this is an example:
Pop Classification =
IF(Population[Pop] >= 1000 && Population[Pop] <= 25000,
1,
IF(Population[Pop] >= 25001 && Population[Pop] <= 50000,
2,
0)
) - 10 years ago
I copied exactly what you posted and it worked for me. Make sure your data is of type Decimal and not Text.
- 10 years ago
Figured it out... or at least partially... it's summarizing data when it shouldn't so it's adding it somewhere.
So all of your suggestions have helped! :) Thank you!!
- 10 years ago
I was about to tell you that. Check the table fields for an aggregate function.
MohammadGhaheri
4 years agoNew Member
Using Switch statement in PowerBI DAX to split Range of Numbers
If you want to split range of Numbers into same length parts and labeling them or classifying them using Switch statement, your solution is here.
Switch statement don't support between and it just works with constant values.
Here I mentioned a simple mathematical trick to split ranges of numbers into same length parts and label them using Dax Switch statement.
Switch statement don't support between and it just works with constant values.
Here I mentioned a simple mathematical trick to split ranges of numbers into same length parts and label them using Dax Switch statement.
you can watch my video here:
https://youtu.be/APWhsxg7NQU