Forum Discussion

cosmicyes's avatar
cosmicyes
Helper II
4 years ago
Solved

Turn a String into a Date

I got some data from a very old ERP-System. The date in the csv-file is this way: * 80520 for May 8 2020 * 110520 for May 11 2020 So the string can have 5 or 6 characters. I solved it myself usi...
  • moizsherwani's avatar
    4 years ago

    Not sure why the DAX formula you created is complicated. See below which works fine for your sample data. You can just create this as a calculuated column.

    Date =
    VAR YearVal =
        "20" & RIGHT ( 'Table'[ERP System], 2 )
    VAR MonthVal =
        LEFT ( RIGHT ( 'Table'[ERP System], 4 ), 2 )
    VAR DateVal =
        LEFT ( 'Table'[ERP System], LEN ( 'Table'[ERP System] ) - 4 )
    RETURN
        DATE ( YearVal, MonthVal, DateVal )