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.
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)
Solved! Go to Solution.
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 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
Hi @Anonymous ,
Any update?😃
Best Regards,
Gao
Community Support Team
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 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
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.
I wanna filter by date range and also include a string, so I can categorise those in that filter.
Hi,
I still do not understand. Share some data and show the expected result.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
109 | |
96 | |
77 | |
66 | |
54 |
User | Count |
---|---|
144 | |
104 | |
102 | |
88 | |
63 |