Forum Discussion
Problem with cannot convert text into date type
I have a table [example] like this:
| submit_date | close_date | ID |
| 04/01/2022 | 08/01/2022 | A123 |
| 05/06/2023 | 14/07/2023 | A124 |
and my dax code to return the table which have date differences:
TABLE =
VAR table =
SUMMARIZE('example', [ID])
RETURN
GENERATE (
table,
VAR tableId = 'example'[ID]
VAR SubDate = LOOKUPVALUE('example'[submit_date], 'example'[ID], [ID], 'example'[submit_date], "submitted_date")
VAR SubDateCalc = DATEVALUE(SubDate)
VAR CloseDate = LOOKUPVALUE('example'[tclose_date], 'example'[ID], [ID], 'example'[close_date], "closed_date")
VAR CloseDateCalc = DATEVALUE(CloseDate)
However, while run this Dax command, having error with VAR SubDateCalc and VAR CloseDateCalc.
It keep giving me error that cannot convert text into date value..
Anyone know the solution? Thanks!
2 Replies
- Martin_DSolution Sage
Hi heejinyune ,
The easier place to reliably convert date as text to date as date-datatype is in Power Query using the "with locale" type conversion.
In DAX you can replace all occurrences ofDATEVALUE ( 'Table'[Date Text] )with
DATE ( VALUE ( RIGHT ( 'Table'[Date Text], 4 ) ), VALUE ( LEFT ( RIGHT ( 'Table'[Date Text], 7 ), 2 ) ), VALUE ( LEFT ( 'Table'[Date Text], 2 ) ) )The behavior of DATEVALUE depends on the Culture property of your dataset, so some users might have the same problem and some not. With my de-de culture there was no problem as you described. Anyway, with the code above you are an the save side, as long as your data format is always two digits day,two digits month,4 digits year.
- AnonymousNot applicable
Hi heejinyune ,
There are several reasons why you might be getting an error that says "cannot convert text into date value" in Power BI Desktop when using DAX. One possible reason is that the DATE object is getting transformed into a DATETIME in Power BI. Another possible reason is that the regional settings in Power BI Desktop are incorrect. To resolve this issue, you can try changing the regional settings in Power BI Desktop to your country/region. Please refer to
Change Type Using Locale with Power Query
Power Query Change Type Using Locale - YouTube
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.