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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Community Champion
Community Champion

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
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

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

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.