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
DIROPS
Frequent Visitor

Date difference between time values in the same column

 

test.jpgHi all, trying my hand at developing some dashboards for plant production tracking and throughput purposes.  New user to Power BI and to DAX.  Wanted to see if I could get some help.  I need to calculate the gap between timestamps in the same column and populate the result in another new column.  The data I am trying to work with is in the Actual Time Column, any help would be appreciated.

 

1 ACCEPTED SOLUTION

hi, @DIROPS 

It's pleasant that your problem has been solved, could you please mark the reply as Answered?

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-lili6-msft
Community Support
Community Support

hi, @DIROPS 

You could refer to this post:

https://community.powerbi.com/t5/Desktop/Calculating-difference-between-rows-Duration/m-p/648300#M31...

Step1:

Add an Index column based on Created Date clolumn

You could do this in Edit Queries or use Rankx Function

Step2:

Create a column by this formula

 

Duration = DATEDIFF('Table'[Created Date],CALCULATE(MAX('Table'[Created Date]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])+1)),SECOND)

Result:

4.JPG

If not your case, please share your expected output.

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

 

Best Regards,

Lin

 

 

 

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

thank you for the help, that got it for me!

hi, @DIROPS 

It's pleasant that your problem has been solved, could you please mark the reply as Answered?

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
AlB
Super User
Super User

Hi @DIROPS 

 

You can just subtract one column from the other. Take into account that the DateTime data type in DAX is a floating-point number internally, wherein the integer corresponds to the number of days since December 30, 1899, and the decimal part identifies the fraction of the day. Have a look at this     

DIROPS
Frequent Visitor

Thank you for the quick response and the redirect to the outside reference I will bookmark that for review as it looks like a great resource!.  However, I dont think I asked my question the right way, I need to subtract one row entry from the actual time column from the next, that way I can see the interval between each entry in that single column with the result propulating another column. Any thoughts?

Can you post sample data and the expected result based on that data? So that it is clear what exactly you need. 

Please always show your sample data in text-tabular format in addition to (or instead of) the screen captures. That allows people trying to help to readily copy the data and run a quick test, plus it increases the likelihood of your question being answered. Just use 'Copy table' in Power BI and paste it here. Or, ideally, share the pbix (beware of confidential data).

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