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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply

Help with Switch Error

Working on getting a traffic light set up, have a column set up to determine the date difference between two dates. Now need to convert that number into a color, this is what I had set up but getting error message. ("DAX comparison operations do not support comparing values of type Text with values of type Integer. Consider using the VALUE or FORMAT function to convert one of the values.")

 

This is the data: 

Project NameApproved ISDProjected ISDSchedNumDaysSchedHealth
112/31/202512/31/20250Green
2 2/28/2025 Green
33/31/20253/31/2026365Red
49/30/20259/30/20250Green
53/31/20263/31/20260Green
6 12/31/2026 Green
79/30/20259/30/20250Green
812/31/20242/15/202546Yellow
99/30/20259/30/20250Green
1012/31/202412/31/20240Green
119/30/20259/30/20250Green
12 12/31/2026 Green
13 3/1/2027 Green
148/30/20241/21/2025144Red
159/30/20249/30/20240Green
 
and here is my SWITCH statement:
SchedHealth = SWITCH(True(),
'Active Projects'[SchedNumDays]="","Green",
'Active Projects'[SchedNumDays]>90,"Red",
'Active Projects'[SchedNumDays]<=0,"Green",
'Active Projects'[SchedNumDays]<90,"Yellow")
1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

I'm confused by the first sentence.

It looks to me that you want to treat it as a number, so it should be a number datatype.  However, the error is caused by using two different types of comparison: one string comparison and one number comparison.

'Active Projects'[SchedNumDays] = ""
'Active Projects'[SchedNumDays] > 90

--

I think if I was you I would convert the datatype to number and alter the switch statement to test for BLANK or null or whatever these empty values get converted to.

View solution in original post

6 REPLIES 6
HotChilli
Super User
Super User

I'm confused by the first sentence.

It looks to me that you want to treat it as a number, so it should be a number datatype.  However, the error is caused by using two different types of comparison: one string comparison and one number comparison.

'Active Projects'[SchedNumDays] = ""
'Active Projects'[SchedNumDays] > 90

--

I think if I was you I would convert the datatype to number and alter the switch statement to test for BLANK or null or whatever these empty values get converted to.

thank you! that worked, apologies on being confusing. 

HotChilli
Super User
Super User

I'm talking about the DAX code. There is a difference on one of the comparison cases.

The error message is giving you the solution to deal with it.

got it, the column was not created with the incoming data so I can't find it in the query. I have to recreate the columns in the query so that I can set them to the correct data type, correct?

HotChilli
Super User
Super User

Look at the values you are comparing in each case. Are they the same datatype or are they different datatypes?

both columns are Text data type

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.