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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
Magomed
Helper I
Helper I

DATEDIFF between Rows

Hello,  

 

I have a question about how to calculate datediff between rows. I have dataset like below: 

 

Trackingtockencreatedon
101.08.2018 08:00
101.08.2018 08:01
101.08.2018 08:12
101.08.2018 08:14
101.08.2018 08:15
101.08.2018 10:31

 

What I need is a calculated column where datediff (MIN or HOUR) between each row is calculated (from the very beginning).

 

Something like the outcome below (based on my example): 

 

Datediff

0

1

11

2

1

....

 

 

Could you please help me with that?

 

Regards

Magomed.

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

HI, @Magomed

After my test, you could do these follow my steps as below:

Step1:

Add a group rank column 

group rank = RANKX(FILTER(Table1,Table1[Trackingtocken]=EARLIER(Table1[Trackingtocken])),Table1[createdon],,ASC)

Step2:

Use EARLIER Function add a datediff column

Datediff = DATEDIFF(CALCULATE(MAX(Table1[createdon]),FILTER(Table1,Table1[Trackingtocken]=EARLIER(Table1[Trackingtocken])&&Table1[group rank]=EARLIER(Table1[group rank])-1)),Table1[createdon],MINUTE)

Result:

6.PNG

here is pbix, please try it.

https://www.dropbox.com/s/0v0qnnue9j1hvyx/DATEDIFF%20between%20Rows.pbix?dl=0

 

Best Regards,

Lin

 

 

 

 

Community Support Team _ Lin
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

4 REPLIES 4
v-lili6-msft
Community Support
Community Support

HI, @Magomed

After my test, you could do these follow my steps as below:

Step1:

Add a group rank column 

group rank = RANKX(FILTER(Table1,Table1[Trackingtocken]=EARLIER(Table1[Trackingtocken])),Table1[createdon],,ASC)

Step2:

Use EARLIER Function add a datediff column

Datediff = DATEDIFF(CALCULATE(MAX(Table1[createdon]),FILTER(Table1,Table1[Trackingtocken]=EARLIER(Table1[Trackingtocken])&&Table1[group rank]=EARLIER(Table1[group rank])-1)),Table1[createdon],MINUTE)

Result:

6.PNG

here is pbix, please try it.

https://www.dropbox.com/s/0v0qnnue9j1hvyx/DATEDIFF%20between%20Rows.pbix?dl=0

 

Best Regards,

Lin

 

 

 

 

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

Hi Lin, 

 

Thank you very much, it worked for me :). 

 

Regards

Magomed.

Greg_Deckler
Community Champion
Community Champion

See my article on Mean Time Before Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi Greg, 

 

Thanks a lot! I will test your approach. 

 

Regards

 

Magomed.

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors