How to create a new column converting date to text

本秂侑毒 提交于 2021-02-11 15:07:44


I need to create a new column with an IF.

If the difference between two dates is more than a month I have to use a text-like "much time" but if it is not I have to show a date.

So the date must be converted to a string to use a text column. How can I convert date to text?

Fecha_real =
IF( DATEDIFF(ventas[fecha_pedido]; ventas[fecha]; month) = 1 ;
    "much time";
    ConvertToTextInSomeWay  ventas[fecha]


This is pretty simple with the FORMAT function.. For example, FORMAT(ventas[fecha], "Short Date") will convert fecha into textlike "12/31/2018".

That's just one format example. There are plenty of pre-defined and custom options if you'd rather something else. For example, FORMAT(ventas[fecha], "dd-mm-yyyy") would format that same date as "31-12-2018" instead.