This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi,
I have data that has timestamp in sigle row. I want to calculate the difference (in seconds or minuites) between two timestamps and need to show in another column or measure. Can anyone please help. Below is the screenshot of data.
Solved! Go to Solution.
Hi @tameemyousaf ,
Check the formula.
Column =
var lasttime = CALCULATE(MAX('Table'[timestamp]),FILTER('Table','Table'[timestamp]<EARLIER('Table'[timestamp])))
return
IF(ISBLANK(lasttime),BLANK(),DATEDIFF(lasttime,'Table'[timestamp],MINUTE))
Best Regards,
Jay
Hi @tameemyousaf ,
Check the formula.
Column =
var lasttime = CALCULATE(MAX('Table'[timestamp]),FILTER('Table','Table'[timestamp]<EARLIER('Table'[timestamp])))
return
IF(ISBLANK(lasttime),BLANK(),DATEDIFF(lasttime,'Table'[timestamp],MINUTE))
Best Regards,
Jay
@tameemyousaf
Can you explain with an example based on your sample data?
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@tameemyousaf
You can add the following New Column to your table to get the time difference in seconds.
Difference =
var __datetime = Table20[Date] + Table20[Time]
var __predatetime =
MAXX(
FILTER(
ADDCOLUMNS(
Table20,
"@DateTime",
Table20[Date] + Table20[Time]
),
[@DateTime] < __datetime
),
[@DateTime]
)
return
DATEDIFF( __predatetime,__datetime,SECOND )
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
@Fowmy Thanks for your reply. I have only one timestamp column. In this case what will be the value of _dateTime variable.
@tameemyousaf
This should work:
Difference =
var __datetime = Table20[DateTime]
var __predatetime =
MAXX(
FILTER(
ALL(Table20[DateTime]),
Table20[DateTime] < __datetime
),
Table20[DateTime]
)
return
DATEDIFF( __predatetime,__datetime,SECOND )
⭕ Subscribe and learn Power BI from these videos
⚪ Website ⚪ LinkedIn ⚪ PBI User Group
you can try this
Column =
VAR last=MAXX(FILTER('Table','Table'[Timestamp]<EARLIER('Table'[Timestamp])),'Table'[Timestamp])
return if(ISBLANK(last),0,round(('Table'[Timestamp]-last)*3600*24,0))
pls see the attachment below
Proud to be a Super User!
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 32 | |
| 26 | |
| 25 | |
| 24 | |
| 15 |
| User | Count |
|---|---|
| 63 | |
| 48 | |
| 27 | |
| 23 | |
| 20 |