Forum Discussion
Function 'SWITCH' does not support comparing values of type True/False with values of type Date.
I am trying to create a condition in DAX using a String and the same time a date range.
But I got this error: Function 'SWITCH' does not support comparing values of type True/False with values of type Date.
Any ideas?
course length 1 = IF ('TOTAL'[Graduation Institution]="TAFE SA",
SWITCH(TRUE(),
DATESBETWEEN('TOTAL'[Orig Policy Start Date], DATE(2015,01,01), DATE(2015,06,30)),1,
0),0)
- Anonymous4 years ago
Hi Anonymous ,
Datesbetween() returns a single-column date table. The formula cannot be compared with a table using Boolean values, so an error is reported.
I guess what you want to find is to match the rows of 'TOTAL' [Orig Policy Start Date] that meet between DATE(2015,01,01) and DATE(2015,06,30). Please try this:
course length 1 = IF ( 'TOTAL'[Graduation Institution] = "TAFE SA", IF ( MAX ( 'TOTAL'[Orig Policy Start Date] ) >= DATE ( 2015, 01, 01 ) && MAX ( 'TOTAL'[Orig Policy Start Date] ) <= DATE ( 2015, 06, 30 ), 1, 0 ), 0 )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
5 Replies
- Ashish_Mathur
Super User
Hi,
The second input of the SWICH() function should result in a TRUE()/FALSE() expression. That is not happening in our formula. Describe the question and share some sample dataset.
- AnonymousNot applicable
I wanna filter by date range and also include a string, so I can categorise those in that filter.
- Ashish_Mathur
Super User
Hi,
I still do not understand. Share some data and show the expected result.
- AnonymousNot applicable
Hi Anonymous ,
Datesbetween() returns a single-column date table. The formula cannot be compared with a table using Boolean values, so an error is reported.
I guess what you want to find is to match the rows of 'TOTAL' [Orig Policy Start Date] that meet between DATE(2015,01,01) and DATE(2015,06,30). Please try this:
course length 1 = IF ( 'TOTAL'[Graduation Institution] = "TAFE SA", IF ( MAX ( 'TOTAL'[Orig Policy Start Date] ) >= DATE ( 2015, 01, 01 ) && MAX ( 'TOTAL'[Orig Policy Start Date] ) <= DATE ( 2015, 06, 30 ), 1, 0 ), 0 )Best Regards,
Gao
Community Support TeamIf there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!
How to get your questions answered quickly -- How to provide sample data
- AnonymousNot applicable
Hi Anonymous ,
Any update?😃
Best Regards,
Gao
Community Support Team