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

July 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more

Reply
rpinxt
Solution Sage
Solution Sage

Count time between rows

Probably not that difficult but still I am strugling.

Here is the issue:

rpinxt_0-1708612675127.png

I want to make a measure that shows me how many time each step took.

So second line would be 7:34 -/- 7:32 resulting in 2 minutes.

 

Etc.

 

6 REPLIES 6
rpinxt
Solution Sage
Solution Sage

Thanks @Greg_Deckler bit more difficult then I was expecting.

 

Tried it like this but no luck yet :

Time Spent =
VAR __Current = MAX('Table 1'[Time])
VAR __PreviousDate = MAXX(FILTER('Table 1','Table 1'[Time] < EARLIER(MAX('Table 1'[Time]),1)

VAR __Previous = MAXX(FILTER('Table 1','Table 1'[Time]=__PreviousDate),[Value])
RETURN
  __Current - __Previous
 
But it starts to go wrong in the EARLIER part....

@rpinxt Can you post your data as text?



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...

@Greg_Deckler  you mean like this?

 

DateNameTimeProcess
01-02-24ALHAJJX 07:32:47Sumtotal
01-02-24ALHAJJX 07:34:54Apply
01-02-24ALHAJJX10:32:36Pauze Uit
01-02-24ALHAJJX10:51:13Pauze Uit
01-02-24ALHAJJX11:24:17Apply
01-02-24ALHAJJX12:30:54Pauze In
01-02-24ALHAJJX13:05:07Pauze Uit
01-02-24ALHAJJX15:01:02Pauze In
01-02-24ALHAJJX15:19:09Pauze Uit
01-02-24ALHAJJX15:36:23Apply
01-02-24ALHAJJX15:57:11Stop

@rpinxt Perfect! Try this (PBIX is attached below signature)

 

Time Spent (Minutes) = 
    VAR __Current = [Time]
    VAR __Previous = MAXX(FILTER('Table 1','Table 1'[Time] < __Current),[Time])
    VAR __Result = IF( __Previous = BLANK(), 0, ( __Current - __Previous ) * 1. * 24 * 60)
RETURN
    __Result

 



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...

Thanks very much Greg.

First thought you made a measure but this is calculated column correct?

Works like a charm.

 

But I have a new concern now....

Out columns have a different order, I set that order in a table visual.

rpinxt_0-1708617547508.png

I tried changing the columns in the query editor but the original order remains in the table view in Power BI.

 

Is there another solution to change the order of the columns then change it in the source?

Greg_Deckler
Community Champion
Community Champion

@rpinxt See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous



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...

Helpful resources

Announcements
Fabric Community Sticker Design Challenge Barcelona Carousel

Fabric Community Sticker Challenge - Barcelona 2026

If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!

July Power BI Update Carousel

Power BI Monthly Update - July 2026

Check out the July 2026 Power BI update to learn about new features.

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