Forum Discussion

athomp15's avatar
athomp15
Helper I
7 years ago

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

  • Mariusz's avatar
    Mariusz
    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