Forum Discussion
Convert Measure Text type into Date-Time Type
I have written 2 measures which gives me date value and time value.
SelectedDate = SELECTEDVALUE(New[BEGIN_DATE])
SelectedTime = SELECTEDVALUE(DateRange[TimeRange])
these both data type is date and time.
But when i try to combine these both measure values as below
Selected Date-Time Range = [SelectedDate]&" "&[SelectedTime]
It is becoming type text and i cant even change the type to date-time(DD:MM:YYYY HH:MM:SS TT)
I tried with TRUNC function from here
https://www.sqlbi.com/blog/marco/2016/12/06/format-measures-as-dates-in-power-bi-dax-powerbi/
Selected Date-Time Range = TRUNC([SelectedDate]&" "&[SelectedTime])+DATE ( 1899, 12, 30 )
Well it is getting converted into date-time type but here im missing the time values
Can anyone please help to get this done.
Thanks You.
Mohan V
9 Replies
- johnt75Super User
Try
SELECTEDVALUE ( Table[Date] ) + SELECTEDVALUE ( Table[Time] )
- AnonymousNot applicable
Thank you. Giving it a shot. Much appreciated.
- prateekrainaMemorable Member
Hi Anonymous,
Here is the required DAX.
DateTime = DATEVALUE ( SELECTEDVALUE ( Table[Date] ) & " " & SELECTEDVALUE ( Table[Time] ) )Enjoy !!
Prateek Raina
- AnonymousNot applicable
prateekraina thanks for the reply
i tried this but didnt worked.
Selected Date-Time Range = DATEVALUE ( SELECTEDVALUE ( New[BEGIN_DATE] ) & " " & SELECTEDVALUE(DateRange[TimeRange]))Not giving the time value.
- prateekrainaMemorable Member
Hi Anonymous,
Check out this short video. You can achieve this in the Power Query Editor itself.
No need for DAX measures.
Prateek Raina
- uk_tjAdvocate IV
Bit late but try adding the date to the time...