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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
mtrevisiol
Helper V
Helper V

Datediff between columns, grouped by users

Hi everyone. I've got this table:

mtrevisiol_0-1633525082182.png

 

which contains only columns from my dataset.

I've grouped it by OpID by summarizing the table selecting the oldest TimeStart and the most recent TimeStop:

 

mtrevisiol_1-1633525128756.png

 

Now my purpose is to calculate the difference between "Prime TimeStart" (the oldest) and "Ultime TimeStop" (the most recent), by creating a measure or a calculated column. How can I do it? Here is the file: https://www.dropbox.com/s/5yurqav2acq9vlw/datediff.pbix?dl=0

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION

Hi, @mtrevisiol 

Try formula as below:

Diff = CALCULATE(MAX(data[TimeStop]))-CALCULATE(MIN(data[TimeStart]))

72.png

Best Regards,
Community Support Team _ Eason

View solution in original post

7 REPLIES 7
Anonymous
Not applicable

if you want it per OpID

i will try calculated columns : (if you want it in minutes)

diff =
DATEDIFF([Ultime TimeStop] ), [Prime TimeStart]), MINUTE )

 

https://docs.microsoft.com/en-us/dax/datediff-function-dax 

@Anonymous 

thanks but the problem is that "Prime Time Start" and "Ultime Time Stop" are not columns. They represent the way the rows are grouped: for the oldest starttime and the most recent stoptime:

 

mtrevisiol_0-1633527858199.png

 

 

Anonymous
Not applicable

Can you group them in PowerQuery ? (instead of in the visual)

@Anonymous maybe I can duplicate the table and then modify it in PowerQuery. How do tou suggest to do it?

Hi, @mtrevisiol 

Try formula as below:

Diff = CALCULATE(MAX(data[TimeStop]))-CALCULATE(MIN(data[TimeStart]))

72.png

Best Regards,
Community Support Team _ Eason

amitchandak
Super User
Super User

@mtrevisiol , Try measure like

 


sumx(values(Table[OpId]), datediff(min(Table[prime start time]), max(Table[Ultime TimeStop])))

 

or


calculate(sumx(values(Table[OpId]), datediff(min(Table[prime start time]), max(Table[Ultime TimeStop]))), allexcept(Table, Table[OpId]))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak thanks but the problem is that "Prime Time Start" and "Ultime Time Stop" are not columns. They represent the way the rows are grouped: for the oldest starttime and the most recent stoptime:

 

mtrevisiol_0-1633527684869.png

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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