Forum Discussion
The syntax for 'AND' is incorrect ALSO DAX comparison operations do not support comparing values of
I want to use a double IF statement for the following:
(DAX(
IF('RRR items'[StatusName]="Rem Completed" AND 'RRR items'[Completed Date] <> "null", 'RRR items'[Completed Date], 'RRR items'[TaskUpdatedOn] ))).
Completed Date and TaskUpdatedOn are date fields and I get an error for the AND and when I use two IF statements i get an error for comparing date type to text. Please help!
Fix Comp Date = IF( 'RRR items'[StatusName]="Rem Completed" AND 'RRR items'[Completed Date] <> 0, 'RRR items'[Completed Date], 'RRR items'[TaskUpdatedOn] )
Fix Comp Date = SWITCH(TRUE(), 'RRR items'[StatusName]="Rem Completed",'RRR items'[Completed Date], 'RRR items'[Completed Date] <> "null", 'RRR items'[TaskUpdatedOn] )
ERROR: DAX comparison operations do not support comparing values of type Date with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.
- Anonymous7 years ago
Hi Anonymous
It seems that problem is with this statement.
'RRR items'[Completed Date] <> "null"
try to use
NOT(ISBLANK( 'RRR items'[Completed Date]))
I hope this will solve your problem of comparing date column with text column. Thanks.
- Anonymous7 years ago
Hi, AND( x,y) only supports 2 parameters. So, better to use && . (x && Y && z)
Power BI will always consider NULL as BLANK(). Whenever we want to check ISNULL then ISBLANK().
4 Replies
- MFelix
Super User
Hi Anonymous ,
First of all DAX is similar to EXCEL so AND is not used in the middle of the comparisions but with a AND(parameter 1 , parameter 2 ), however is possible to use a similar syntax using the && (and) || (or) so you should redo your measure to:
Fix Comp Date = IF ( 'RRR items'[StatusName] = "Rem Completed" && 'RRR items'[Completed Date] <> 0, 'RRR items'[Completed Date], 'RRR items'[TaskUpdatedOn] )Regarding the second part of your question believe this as to do with the fact that you are incorrectly writing the swithc function this should be rewritten to:
Fix Comp Date = SWITCH ( TRUE (), 'RRR items'[StatusName] = "Rem Completed", 'RRR items'[Completed Date], 'RRR items'[Completed Date] <> null, 'RRR items'[TaskUpdatedOn] )Looking at the syntax as you have written it you are comparing the Completed date with "null" so text value and not the if the value of the column is null, so that is why is giving the error of comparision of values.
However if this formula is to be similar to the first one should be rewritten to:
Fix Comp Date = SWITCH ( TRUE (), 'RRR items'[StatusName] = "Rem Completed" && 'RRR items'[Completed Date] <> null, 'RRR items'[Completed Date], 'RRR items'[TaskUpdatedOn] )Regards,
MFelix
- Nathaniel_C
Community Champion
Hi Anonymous ,
Try &&, and you might have too many ) at the end.
Let me know if you have any questions.
If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel - AnonymousNot applicable
Hi Anonymous
It seems that problem is with this statement.
'RRR items'[Completed Date] <> "null"
try to use
NOT(ISBLANK( 'RRR items'[Completed Date]))
I hope this will solve your problem of comparing date column with text column. Thanks.
- AnonymousNot applicable
Hi, AND( x,y) only supports 2 parameters. So, better to use && . (x && Y && z)
Power BI will always consider NULL as BLANK(). Whenever we want to check ISNULL then ISBLANK().