cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Helper I
Helper I

DAX Time compare (same column next row)

Hi All, I've solved this issue in Power Query, but would prefer a DAX solution. I've tried a EARLIER function, but can't quite get the results I need. Anyhow I have a table that looks like the following.  What I would like to do is to calculate the time difference between each page access.

 

userpage urldate/time accessed
joepage 112/11/2019 10:00:01
fredpage 112/11/2019 10:00:01
joepage 312/11/2019 10:00:04
joepage 412/11/2019 10:00:05
fredpage 512/11/2019 10:00:07
fredpage 612/11/2019 10:00:08
fredpage 712/11/2019 10:00:21
joepage 812/11/2019 10:00:22
fredpage 912/11/2019 10:00:22
joepage 1012/11/2019 10:00:30

 

So when in a Table visual I get something along the lines of

 

userpage urldate/time accessedTime on page (s)
joepage 112/11/2019 10:00:013
joepage 312/11/2019 10:00:041
joepage 412/11/2019 10:00:051
joepage 812/11/2019 10:00:2217
joepage 1012/11/2019 10:00:30 

 

Any help would be greatly appreciated.

Thanks

Alex

1 REPLY 1
Super User III
Super User III

Hi @athomp15 

 

Is the below Measure any help?

Measure = 
VAR mdt = MAX(YourTable[date/time accessed])
RETURN 
DATEDIFF(
    mdt,
    CALCULATE(
        MIN(YourTable[date/time accessed]),
        ALLEXCEPT(YourTable, YourTable[user]),
        YourTable[date/time accessed] > mdt
    ),
    SECOND
)


Hope this helps

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors