Forum Discussion
Create a new column with DAX
- 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
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- Anonymous4 years agoNot 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- danextian4 years ago
Super 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]) )
- danextian4 years ago
Super User
As mentioned, the solution will depend on the data type. Is it a text or a datetime?