Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Can't convert text to date

Hi guys, I am newbie in powerbi  I have this column with dates like '20180101' which is supposed to be 2018-01-01.  I tried converting it in the modelling but received this error message.   "...
  • DoubleJ's avatar
    7 years ago

    That's interesting because I was able to transform the exact same string to a date using the Power BI Transform functionality.

     

    However, you could add a calculated column that does the transformation

     

    DateColumn = 
    DATE(
        LEFT('Table'[DateString],4,
        MID('Table'[DateString],5,2),
        RIGHT('Table'[DateString],2))

    You have to make sure that the string always has the same format YYYYMMDD.

     

    Hope this helps

    JJ