3

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

3
  • 1
    You probably want to use a Calculated Column, not a Measure. Commented Apr 13, 2021 at 1:05
  • Thanks for the suggestion @Mankarse, would that work for DirectQuery? Commented Apr 14, 2021 at 1:43
  • How do you intend to use this date field? Commented Apr 14, 2021 at 14:11

3 Answers 3

2

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]
Sign up to request clarification or add additional context in comments.

1 Comment

Hi thanks for the answer, I forgot to mention that I'm using DirectQuery data. It caught error This query contains transformations that can't be used for DirectQuery. when I tried to create a new column.
2

Can you please try this below Measure-

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

3 Comments

Hi thank you for the answer. I tried and it seems like the date format is wrong, please see edited question.
Hi @nilsinelabore, this is because the last part *1 I guess. Just remove that part and try again.
Thank you for your suggestion. I tried to remove *1 but I don't think it's what I wanted. I want to convert timestamp to date so I can count the events in each day but this method seems to extract only one day...
1

When you use INT() function it will remove the time from the dates, so from "03/05/2024 04:13:00" Will make "03/05/2024 00:00:00"

So you just duplicate with INT

Date = INT('my_table'[Timestamp])

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.