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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.