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

The FabCon + SQLCon recap series starts April 14th at 8am Pacific. If you’re tracking where AI is going inside Fabric, this first session is a can't miss. Register now

Reply
Irwan
Super User
Super User

Need Advice: How to Calculate Date Diff between Two Exact Event

Hello Power BI Experts,

I need an advice about my dataset.

 

Below is my data.

My need is to find the next row that contains the exact string (description) for example "replace" with the exactly same equipment number as both in yelow color below, then substract the date of that row with date of current row (yellow color). And the process continue until last row of data (next date of the data will be substract to previous date of the data).

Irwan_1-1687232143188.png

To make it simple, I want to calculate date difference between two events with exact description and equipment number.

 

Thank you and really appreciated for the help.

1 ACCEPTED SOLUTION
Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26RiQZUXnY1lqz0ovDw?e=ufVd4q

Screen Capture #1288.png

View solution in original post

10 REPLIES 10
Irwan
Super User
Super User

Hello @Ahmedx 

 

thanks, everything is working, got all my need to shape my database.

 

thank you and really appreciated for all the help.

Ahmedx
Super User
Super User

Based on your description, I created data to reproduce your scenario. The pbix file is attached in the end.

https://1drv.ms/u/s!AiUZ0Ws7G26RiQZUXnY1lqz0ovDw?e=ufVd4q

Screen Capture #1288.png

Hello @Ahmedx 

 

one last question, can we move the data in "Count of Days" into separate table or column accordingly to its "ID" and then sort it out in ascending order?

 

Thank you again.

hello @Ahmedx 

 

thanks, it moved to new table, however the days are summed in the new table according to ID. Is there a way not to sum the days in the new table?

 

the expected new table is going to be like this 

IDDay
6000000002638298
6000000002638377

 

and also is it possible to automatically sorted "day" column in ascending order after it moved to new table?

 

Thank you again, really appreciated for the help.

pls try this

Screen Capture #1295.png

Hello @Ahmedx 

 

It works perfectly.

 

Thank you and really appreciated for all the help.

Hello @Ahmedx 

 

thank you for the code, it works as my need.

 

Thanks again for the support.

Ahmedx
Super User
Super User

Share some data to work with (in a format the can be pasted in an MS Excel file) and show the expected result.

hello @Ahmedx ,

 

here is sample of the data to make it simpler.

The expected result is

1. 298 (from 16-Dec-19 till 9-Oct-20), days difference between line 2 and line 9.

2. 377 (from 9-Oct-20 till 16-Dec-19), days difference between line 9 and line 13.

Those three events have exactly same description and equipment number.

1600000001974Replace pulley8-Oct-19
2600000002638Replace motor16-Dec-19
3600000083190Replace pulley27-Jan-20
4600000002693Replace pulley12-May-20
5600000002616Replace pulley26-May-20
6600000083190Replace pulley6-Jun-20
7600000002638Replace pulley7-Jul-20
8600000003106Replace pulley21-Sep-20
9600000002638Replace motor9-Oct-20
10600000002693Replace pulley29-Jul-21
11600000002645Replace pulley19-Aug-21
12600000002624Replace pulley15-Oct-21
13600000002638Replace motor21-Oct-21

Thank you and appreciated with the help.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.