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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
DRJ1994
Helper I
Helper I

Help with SWITCH Statement

Hi guys, 

Hope you can help. I am trying to use a switch statement to create categories labeled as "0-7 days" "8-30 days" and"30+ days".

However I keep recieving the following error code:

 

"DAX Comparison operations do not support comparing values of type true/false with values of type integer. Consider using the VALUE or FORMAT function to convert one of the values".

I have attached a screenshot of the DAX and error message below:

DRJ1994_0-1653919040304.png

I have checked the 'Days' Data type and it is formatted as a number. Any idea where I am going wrong and how to fix it?

 

Thanks in advance!

DRJ.

1 ACCEPTED SOLUTION
Samarth_18
Community Champion
Community Champion

Hi @DRJ1994 ,

 

Please try this:-

 

length of sickness =
SWITCH (
    TRUE (),
    'Sheet1 (2)'[Days] <= 7, "0-7 days",
    'Sheet1 (2)'[Days] >= 8
        && 'Sheet1 (2)'[Days] <= 30, "8-30 days",
    'Sheet1 (2)'[Days] > 30, "30+ days"
)

 

 

BR,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

View solution in original post

2 REPLIES 2
Samarth_18
Community Champion
Community Champion

Hi @DRJ1994 ,

 

Please try this:-

 

length of sickness =
SWITCH (
    TRUE (),
    'Sheet1 (2)'[Days] <= 7, "0-7 days",
    'Sheet1 (2)'[Days] >= 8
        && 'Sheet1 (2)'[Days] <= 30, "8-30 days",
    'Sheet1 (2)'[Days] > 30, "30+ days"
)

 

 

BR,

Samarth

Best Regards,
Samarth

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
Connect on Linkedin

Thank you so much! That helped and solved my issue!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.