powerbidirectquery

Convert timestamp to date in DAX with DirectQuery


I want to convert a Timestamp column to date column in my table. I tried to create a measure with DAX:

Date = FORMAT('my_table'[Timestamp], "dd/mm/yyyy")*1

and caught error:

A single value for column 'Timestamp' in table 'my_table' cannot be determined. This can happen when a measure formula refers to a column that contains many values without specifying an aggregation such as min, max, count, or sum to get a single result.

but I do not need aggregation here I just need to convert datetime to date.

Timestamp column looks like this:

enter image description here


Tried:

Date = FORMAT(MIN('my_table'[Timestamp]), "dd/mm/yyyy")*1

which gives a weird date format, as I tried to inspect a visual using "show as a table": enter image description here


Solution

  • Create a calculated column not a measure.

    You can simply duplicate the timestamp column and then change the column data type to Date.

    Date = 'my_table'[Timestamp]