Forum Discussion
Create a new column with DAX
Hello!
i have a column like follows:
6/12/2022 2:50:00 PM
6/12/2022 3:42:10 PM
6/12/2022 3:50:17 PM
6/13/2022 1:19:47 AM
6/13/2022 4:12:58 AM
...
I want to create a column which only has the date included:
6/12/2022
6/12/2022
6/12/2022
6/13/2022
6/13/2022
Which DAX Expression do I have to use?
Thanks! 🙂
Hi Anonymous ,
The solution will depend on the data type of the column you're trying to create a calculated column from. If it is a date, you simpley use INT ( Table[Column] ) and format the new column as a date - INT for integer as a datetime is actually a whole number for the date and decimal for the time. Otherswise, if it is a text, the formula will be very simIlar as in Excel.
Date only = VAR __SPACE = FIND ( " ", 'Table'[Date and time] ) - 1 //find the position of space from the left then -1 to get the position before it RETURN VALUE ( LEFT ( 'Table'[Date and time], __SPACE ) ) //VALUE is for converting the text date to actual date
6 Replies
- Greg_DecklerCommunity Champion
Anonymous Well, you could do this:
New Column = DATE(YEAR([Date]),MONTH([Date]),DAY([Date])) - danextianSuper User
Hi Anonymous ,
The solution will depend on the data type of the column you're trying to create a calculated column from. If it is a date, you simpley use INT ( Table[Column] ) and format the new column as a date - INT for integer as a datetime is actually a whole number for the date and decimal for the time. Otherswise, if it is a text, the formula will be very simIlar as in Excel.
Date only = VAR __SPACE = FIND ( " ", 'Table'[Date and time] ) - 1 //find the position of space from the left then -1 to get the position before it RETURN VALUE ( LEFT ( 'Table'[Date and time], __SPACE ) ) //VALUE is for converting the text date to actual date- AnonymousNot applicable
Exactly what I looked for.
But i get an error saying "An argument of function "FIND" hast the wrong data type or has an invalid value".
The used data type is "date/time". danextian- danextianSuper User
FIND is a text function so if a data type other than text is used it will return an error. If you need to extract the date portion of a datetime, you can use INT() or DATE(YEAR(Table[DateTime]), MONTH (Table[DateTime]), DAY(Table[DateTime]) )
- v-yanjiang-msftCommunity Support
Hi Anonymous ,
Is your problem solved?? If so, Would you mind accept the helpful replies as solutions? Then we are able to close the thread. More people who have the same requirement will find the solution quickly and benefit here. Thank you.
Best Regards,
Community Support Team _ kalyjIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.