Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hello All,
I have a table where cloumn1 = Porduct Name , Cloumn 2 = Serial Numbers of products , Cloumn 3 = Repair Work Order Numbers , Cloumn 4 = Work order Created date , Column 5 = Repair Work Order Closed Date . Now i have to find a time difference between last closed repair Work order date w.r.t previous repair closed date . Please suggest
Solved! Go to Solution.
Hi @SAU1111 ,
If the Repair Work Order Numbers is random like below:
You can create a column to rank the Closed Date for each Product Name and Serial Numbers of products, like this:
Rank =
RANKX (
FILTER (
'Table',
'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
&& 'Table'[Serial Numbers of products]
= EARLIER ( 'Table'[Serial Numbers of products] )
),
'Table'[Repair Work Order Closed Date],
,
ASC,
DENSE
)
Then create a measure.
Average Diff =
VAR _T =
ADDCOLUMNS (
'Table',
"Diff",
DATEDIFF (
MAXX (
FILTER (
'Table',
'Table'[Rank]
= EARLIER ( 'Table'[Rank] ) - 1
&& 'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
&& 'Table'[Serial Numbers of products]
= EARLIER ( 'Table'[Serial Numbers of products] )
),
'Table'[Repair Work Order Closed Date]
),
'Table'[Repair Work Order Closed Date],
DAY
)
)
RETURN
AVERAGEX ( _T, [Diff] )
Get the result for each Product Name and Serial Numbers of products.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Sorry I forgot to mention that for 1 Serial numbers there can be N numbers of Work orders and there closed On date . Now problem is that more than 1 serial numbers has same repair work order closed on date . SO WOrk order numbers also be random cannot be arranged as on same day two Work order of a sequence like 1 and 2 can be for different serial numbers . Now First how to arrange by Serial Numbers all the WO and its closed on Date so that i can arrange the dates in ascending order and calculate a difference .
Hi @SAU1111 ,
If the Repair Work Order Numbers is random like below:
You can create a column to rank the Closed Date for each Product Name and Serial Numbers of products, like this:
Rank =
RANKX (
FILTER (
'Table',
'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
&& 'Table'[Serial Numbers of products]
= EARLIER ( 'Table'[Serial Numbers of products] )
),
'Table'[Repair Work Order Closed Date],
,
ASC,
DENSE
)
Then create a measure.
Average Diff =
VAR _T =
ADDCOLUMNS (
'Table',
"Diff",
DATEDIFF (
MAXX (
FILTER (
'Table',
'Table'[Rank]
= EARLIER ( 'Table'[Rank] ) - 1
&& 'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
&& 'Table'[Serial Numbers of products]
= EARLIER ( 'Table'[Serial Numbers of products] )
),
'Table'[Repair Work Order Closed Date]
),
'Table'[Repair Work Order Closed Date],
DAY
)
)
RETURN
AVERAGEX ( _T, [Diff] )
Get the result for each Product Name and Serial Numbers of products.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Hi @SAU1111 ,
According to your descrption, I create a sample.
Here's my solution, create a measure.
Average Diff =
VAR _T =
ADDCOLUMNS (
'Table',
"Diff",
DATEDIFF (
MAXX (
FILTER (
'Table',
'Table'[Repair Work Order Numbers]
= EARLIER ( 'Table'[Repair Work Order Numbers] ) - 1
&& 'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
&& 'Table'[Serial Numbers of products]
= EARLIER ( 'Table'[Serial Numbers of products] )
),
'Table'[Repair Work Order Closed Date]
),
'Table'[Repair Work Order Closed Date],
DAY
)
)
RETURN
AVERAGEX ( _T, [Diff] )
Get the correct result.
I attach my sample below for reference.
Best Regards,
Community Support Team _ kalyj
If this post helps, then please considerAccept it as the solution to help the other members find it more quickly.
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 29 | |
| 27 | |
| 25 | |
| 25 | |
| 18 |
| User | Count |
|---|---|
| 54 | |
| 49 | |
| 43 | |
| 36 | |
| 32 |