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
heathernicole
Continued Contributor
Continued Contributor

SWITCH 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 value" in column is BETWEEN 9999 AND 24999 THEN, (2000)

 

I've already tried writing it using greater than or equal to 10,000 and less than or equal to 24,999 - that didn't work. 

 

I've looked at several switch statement examples but they all use a "If this value = "this" set up and I'm looking for a range.

 

Any pointers or sites that be helpful in figuring out the proper syntax?


THANKS!

~heathernicoale
4 ACCEPTED SOLUTIONS
asocorro
Skilled Sharer
Skilled Sharer

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)
)

 

 

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

View solution in original post

I copied exactly what you posted and it worked for me.  Make sure your data is of type Decimal and not Text.

 

 

2016-02-18_9-55-39.jpg

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

View solution in original post

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!!

~heathernicoale

View solution in original post

I was about to tell you that.  Check the table fields for an aggregate function.

Connect with me in LinkedIn: https://pr.linkedin.com/in/adolfosocorro
Follow me on Twitter: https://twitter.com/AdolfoSocorro

View solution in original post

18 REPLIES 18

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.

Top Solution Authors