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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
athomp15
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
Mariusz
Community Champion
Community Champion

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
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.