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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculate the difference between two times

Hi,

 

I am trying to calculate the difference between two times ("Sluttid" means "End time" ), and ("Sidste opg. **bleep**" means "Last task done"). 

 

"Sluttid" is a column placed in one table called "SD", where "Sidste opg. **bleep**" is a column measure in another table called "Data":

Sidste opg. **bleep** = CALCULATE(MAX(Data[Udført tid]);   ALLEXCEPT(Data;Data[Udfører];   Data[Ønsket dato]))

 

The result I want is that in the first row I will get: 16:00:00-15:59:26 = 34 sek. The next row: 1 minut and 2 sek. And so on....

I have tried datediff and many other things, but nothing seems to work..

 

Can anybody help? 🙂

- Nina

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , not very clear with description

it can be

 

Sidste opg. **bleep** = CALCULATE(datediff(Min(Data[Udført tid]), MAX(Data[Udført tid]), hour); ALLEXCEPT(Data;Data[Udfører]; Data[Ønsket dato]))

Can you share sample data and sample output in table format?

 

 

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Anonymous , not very clear with description

it can be

 

Sidste opg. **bleep** = CALCULATE(datediff(Min(Data[Udført tid]), MAX(Data[Udført tid]), hour); ALLEXCEPT(Data;Data[Udfører]; Data[Ønsket dato]))

Can you share sample data and sample output in table format?

 

 

Anonymous
Not applicable

Hi,

 

Thank you for the help. It helped me out. 

 

The formular I needed was: 

Measure = CALCULATE(DATEDIFF(MIN('Data (raw)'[Sidste opg. **bleep**]);MAX(SD[Sluttid]);MINUTE))
 
I just do not understand why "min" and "max" is needed here. But it do not work without.
-Nina
Pragati11
Super User
Super User

Hi @Anonymous ,

 

Not sure if you looked at few existing threads in the community for same issue:

https://community.powerbi.com/t5/DAX-Commands-and-Tips/Time-Calculation/m-p/1145199

https://community.powerbi.com/t5/Desktop/HIGHLY-URGENT-Calculate-Time-Stamp-Difference/m-p/1210618

 

Thanks,

Pragati

Best Regards,

Pragati Jain


MVP logo


LinkedIn | Twitter | Blog YouTube 

Did I answer your question? Mark my post as a solution! This will help others on the forum!

Appreciate your Kudos!!

Proud to be a Super User!!

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors