Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

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 t...
  • danextian's avatar
    4 years ago

    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