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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

SWITCH DAX error

The formula below is not working for some reason.. Can somebody help correct me?

 

SWITCH (
TRUE,
[Days] < 30, "<30 Days",
[Days] >= 30 && [Days] <= 69, "30-69 Days",
[Days] >= 70 && [Days] <= 100, "70-100 Days",
[Days] >= 101 && [Days] <= 140, "101-140 Days",
[Days] >= 141 && [Days] <= 180, "141-180 Days",">180 Days")

 

The logic is this:

 

IF [Days] <30 THEN "<30 Days"
ELSEIF [Days] >= 30 AND [Days] <= 69 THEN "30-69 Days"
ELSEIF [Days] >= 70 AND [Days] <= 100 THEN "70-100 Days"
ELSEIF [Days] >= 101 AND [Days] <= 140 THEN "101-140 Days"
ELSEIF [Days] >= 141 AND [Days] <= 180 THEN "141-180 Days"
ELSE ">180 Days" END

 

Thank you!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@Anonymous 

maybe try this

SWITCH (
TRUE(),
[Days] < 30, "<30 Days",
 [Days] <= 69, "30-69 Days",
 [Days] <= 100, "70-100 Days",
 [Days] <= 140, "101-140 Days",
 [Days] <= 180, "141-180 Days",">180 Days")

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
Tahreem24
Super User
Super User

@Anonymous What exact error is it showing?

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

Laedays_0-1628752864283.png

this is the error, unexpected expression for those in red line

Jos_Woolley
Solution Sage
Solution Sage

Hi,

I don't see anything wrong with that construction. For which values is it not working? Please give some examples.

Regards

Anonymous
Not applicable

Laedays_1-1628752954402.png

 

You haven't tried to enter that as a measure, as opposed to a calculated column, by any chance?

Regards

ryan_mayu
Super User
Super User

@Anonymous 

maybe try this

SWITCH (
TRUE(),
[Days] < 30, "<30 Days",
 [Days] <= 69, "30-69 Days",
 [Days] <= 100, "70-100 Days",
 [Days] <= 140, "101-140 Days",
 [Days] <= 180, "141-180 Days",">180 Days")

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.