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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Compare between two timestamp with condition

Hello ,

I have this table and i need to compare between the last date (Field2 ) with Field3 (X) and the first row who contain SSE in Field 3

 

Example :  i need to do for this picture 2 calculs : 

First one : it needs to detect Field3 = SSE so it will retrieve the date 02:45 and compare it with the Row X5 (the last row when Field3 = X) 

So : 02:45 - 00:26 = 02:19

and repeting this condition for all the file 

 

example 2 : 2:20 - 00:10 

ZiedAhmed90_0-1686650997861.png

Thank you for all 

 

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

Hi, @Anonymous 

Thanks for your sample data first!

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1686798896109.png

(2)We can create a calcualted column like this:

Column = var _sse_date =  IF([Field3]="SSE" , [StartDate] ,  BLANK())
var _t = FILTER('Table','Table'[StartDate]<_sse_date && 'Table'[Field3]= "X")
var _max_startdate =  MAXX(_t, [StartDate])
var _lastdate= MAXX(FILTER(_t,[StartDate] = _max_startdate) , [LastDate])
return
_sse_date-_lastdate

 

Then we can get the result is as follows:

vyueyunzhmsft_1-1686798927439.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

1 REPLY 1
v-yueyunzh-msft
Community Support
Community Support

Hi, @Anonymous 

Thanks for your sample data first!

Here are the steps you can refer to :
(1)This is my test data:

vyueyunzhmsft_0-1686798896109.png

(2)We can create a calcualted column like this:

Column = var _sse_date =  IF([Field3]="SSE" , [StartDate] ,  BLANK())
var _t = FILTER('Table','Table'[StartDate]<_sse_date && 'Table'[Field3]= "X")
var _max_startdate =  MAXX(_t, [StartDate])
var _lastdate= MAXX(FILTER(_t,[StartDate] = _max_startdate) , [LastDate])
return
_sse_date-_lastdate

 

Then we can get the result is as follows:

vyueyunzhmsft_1-1686798927439.png

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors