Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How can i get a comparisson from a datetime with a time column?

Screenshot 2020-11-27 085451.png

My initial tought was "Oh, the same way we have:

 

'Table'[Column].[Date]

 

 

to compare only 2 dates from columns, we probably have:

 

'Table'[Column].Time

 

 

"
But we dont, then i thought 
I can use "Hour('Table'[Column])" to compare, but nonono, i cant, cuz will only compare the hour, so if an item have the same hours but minutes different it will not make a good comparisson. 

I cant change my Time column to a datetime.
I know i can create a new column just to get my time from my datetime column, but  i would rather know if there is another way.

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a measure as below:

Measure = 
var _datetime=FORMAT(MAX('Table'[Datetime]),"mm/dd/yyyy hh:nn:ss") 
var _time =FORMAT(CONCATENATE(CONCATENATE(FORMAT(MAX('Table'[Datetime]),"mm/dd/yyyy")," "),FORMAT(MAX('Table'[time]),"hh:nn:ss")),"mm/dd/yyyy hh:nn:ss") 
return IF(DATEDIFF(_time,_datetime,HOUR)<=0,"X","Y")

time comparasion.JPG

Best Regards
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

You can create a measure as below:

Measure = 
var _datetime=FORMAT(MAX('Table'[Datetime]),"mm/dd/yyyy hh:nn:ss") 
var _time =FORMAT(CONCATENATE(CONCATENATE(FORMAT(MAX('Table'[Datetime]),"mm/dd/yyyy")," "),FORMAT(MAX('Table'[time]),"hh:nn:ss")),"mm/dd/yyyy hh:nn:ss") 
return IF(DATEDIFF(_time,_datetime,HOUR)<=0,"X","Y")

time comparasion.JPG

Best Regards
Community Support Team _ Rena Ruan
If this post helps, then please consider Accept it as the solution to help the other members find it more.

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
amitchandak
Super User
Super User

@Anonymous , As new column , one of the two

 

if('Table'[Datetime].Time <'Table'[Time] ,"X", "Y")

if(time(Hour('Table'[Datetime]),minute('Table'[Datetime]),second('Table'[Datetime]))<'Table'[Time] ,"X", "Y")

Anonymous
Not applicable

@amitchandak , u sure that the "if('Table'[Datetime].Time <'Table'[Time] ,"X", "Y")" works? 
Cuz when i use the ".Time" it doesnt work. 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.