Forum Discussion
jakubk
5 years agoHelper I
validate date using dax
i have a live connection i need to ID which rows contain invalid dates in a particular string column. the date format should be YYYY-mm-dd I can't do it at the source query I thought i had it w...
- 5 years ago
yeah both months and days that are out of bounds of the month are treated like dateadd() which is not what i want
I think i figured this out yesterday - best way to check is to convert the parsed date back to a string in the expected format and make sure they match
Date Check Calc = VAR rawDate = MIN ( Table[RawData] ) RETURN SWITCH ( TRUE (), // Blank dates aren't an error but surface it differently to OK dates ISBLANK ( rawDate ), 2, // try to parse the date using hardcoded char locations. The date() parser is too forgiving - convert the date back to text and compare it to the raw value to make sure it hasn't been time travelled FORMAT ( IFERROR ( DATE ( LEFT ( rawDate, 4 ), MID ( rawDate, 6, 2 ), MID ( rawDate, 9, 2 ) ), BLANK () ), "YYYY-mm-dd" ) <> rawDate, 1, 0 )
amitchandak
5 years agoSuper User
jakubk , what is wring data expected. One check
if(len([col] <12, blank(), [col])
Now this table can be marked as date in power query with igonre error.
Can you share sample data and