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
Tommyvhod
Helper II
Helper II

Measure to filter days between operations

Hi guys

 

I am quite new to power BI and I am stuck with a report I would like to make.

I have a list of IDs from production. We have in production 50 operations each with different number (e.g-20-50-70-80 ...) after finishing a part on each operation a finish date is added for the given operation. Additional thing is that the order of these operations are not alwazs the same but the IDnumber of the operation is always ascending ( 20-30-50-80 or 20-30-70-80 or 20-70-90 .... )

 

What I would like to make is: for all the IDs know the days between each operation ( and of course the whole production time for one ID) in days. 

 

E.g:

 

ID Operation IDFinish date
48097101. 10. 2019
48097353. 10. 2019
48097504. 10. 2019
48097704. 10. 2019
48097807. 10. 2019
48097909. 10. 2019
4809711011. 10. 2019
4809716511. 10. 2019
4809721013. 10. 2019
48104301. 10. 2019
48104351. 10. 2019
48104502. 10. 2019
48104705. 10. 2019
481041108. 10. 2019
4810413511. 10. 2019
4810418013. 10. 2019
4810419015. 10. 2019.

 

Thank You very much

1 ACCEPTED SOLUTION
Nathaniel_C
Super User
Super User

Hi @Tommyvhod , 

Try these two measures to get the result in the picture. My table name is Fin.
Let me know if you have any questions.

If this solves your issues, please mark it as the solution, so that others can find it easily. Kudos are nice too.
Nathaniel

 

Date diff = 
VAR _Time =
     ( Fin[Finish date] ) //captures current date


Var _maxLastTime = CALCULATE(MAX(Fin[Finish date]),FILTER(ALLEXCEPT(Fin,Fin[ID ]),Fin[Finish date]< _Time))

var _datedif =DATEDIFF(_maxLastTime,Fin[Finish date],day)

return
if(_datedif>0,_datedif,0)

==================

Date Dif per ID = CALCULATE(DATEDIFF(MIN(Fin[Finish date]),MAX(Fin[Finish date]),DAY),Filter(ALLEXCEPT(fin,Fin[ID ]),Fin[ID ])

 

 

 

 

 

Elapsed days.PNG

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

15 REPLIES 15

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