Forum Discussion

viveksasi94's avatar
viveksasi94
Icon for Helper I rankHelper I
7 years ago
Solved

How to substitute a Date with a String without changing the data type to string

Greetings Datanuts, I have a date column whose data type is Date. I need to replace a specific date in the date column with a String. If I change the data type of the column to Text it is not sorting properly(i.e earliest date should come first). Note - MY_MODEL[Snapshot Date] data type is Date/time TEST = IF(MY_MODEL[Snapshot Date]=31/12/9999,"Live",MY_MODEL[Snapshot Date]) Error - Expressions that yield variant data-type cannot be used to define calculated columns. Any help is appreciated :)
  • viveksasi94

     

    I am not sure if I understand your question clearly. I think if you want to return the value as text and date type, you need to unify the type.

     

    In my example, the type of data column is date and the type of date2 type is TEXT.

     

    Hope this is helpful. Thanks

     

    checkdate = if('Table1'[date]=DATE(2018,01,01),"Live",FORMAT('Table1'[date],""))
    checktext = if(Table1[date2]="1/1/2018","Live",Table1[date2])

     

3 Replies