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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Function 'SWITCH' does not support comparing values of type True/False with values of type Date.

Hello all,

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)

 

1 ACCEPTED SOLUTION
v-cgao-msft
Community Support
Community Support

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.

DATESBETWEEN

 

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 Team

 

If 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

View solution in original post

5 REPLIES 5
v-cgao-msft
Community Support
Community Support

Hi @Anonymous ,

 

Any update?😃

 

Best Regards,
Gao

Community Support Team

 

v-cgao-msft
Community Support
Community Support

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.

DATESBETWEEN

 

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 Team

 

If 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

Ashish_Mathur
Super User
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.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

I wanna filter by date range and also include a string, so I can categorise those in that filter.

ZAAX_0-1659578692888.png

 

Hi,

I still do not understand.  Share some data and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.