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

Calculate completed operation and date difference

Hi,

 

I'm trying to calculate Completed? column based on serial #s, operations 10-30 = completed operation based on serial #.

Then calculate the date difference between completed serials (10 and 30 operations).

Is this possible in Power BI?

 

Thank you!

serial #Operation #Date completedCompleted? Op # 10-30
1101/2/2022Y
1201/3/2022Y
1301/5/2022Y
2101/8/2022Y
2201/10/2022Y
2251/12/2022Y
2301/14/2022Y
3101/5/2022N
3201/9/2022N
3251/12/2022N
9 REPLIES 9
vykaizen
Frequent Visitor

Adding && doesn't seem to work.  Appreciate any insight, thank you.

 

Completed? =
VAR __serial = [Serial #]
VAR __table = FILTER('table', [Serial #] = __serial && [Operation] = "10" && [Operation] = "30")
RETURN
IF(COUNTROWS(__table)+0 > 0,"Y","N")

vykaizen
Frequent Visitor

Hi Greg,

To answer your question yes, the operations is noted to be completed starting with 010 Start and 030 Finish to finish.

 

So yes, I need to include the 010 Start to note the completion and not just add the 030.  Is this possible?  Thank you so much for your help.

 

Victor 

@Greg_Deckler 

 

Hi Greg,

To answer your question yes, the operations is noted to be completed starting with 010 Start and 030 Finish to finish.

 

So yes, I need to include the 010 Start to note the completion and not just add the 030.  Is this possible?  Thank you so much for your help.

 

Victor 

Hi,

 

Probably need to add some flexibility as there are different text for starts (i.e., 010 Start, 010 Begin).  All starts operations start with "010".  Thank you.

 

Victor

Greg_Deckler
Super User
Super User

@vykaizen So, yes, as a column:

Completed? Column = 
  VAR __serial = [serial #]
  VAR __table = FILTER('Table',[serial #] = __serial && [Operation #] = 30)
RETURN
  IF(COUNTROWS(__table)+0 > 0,"Y","N")

The second part is essentially MTBF, See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395....
The basic pattern is:
Column = 
  VAR __Current = [Value]
  VAR __PreviousDate = MAXX(FILTER('Table','Table'[Date] < EARLIER('Table'[Date])),[Date])

  VAR __Previous = MAXX(FILTER('Table',[Date]=__PreviousDate),[Value])
RETURN
  __Current - __Previous


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Never mind, I figured it out, thanks so much for your help!

 

H Greg,

 

Appreciate the quick response, and it works based on the Operation #, your the man.  

I tried substituting the Operation # with "010 Start" (It's actually text) , but could not get it to work.  Is there something I need to do?

 

Many thanks!

 

Victor

@vykaizen Hmm, hang on, what are the actual values for 10, 20 and 30 Operation #'s? Also, does a serial # need to have all three Operation # values to be present before it is considered completed or is a single "30" value sufficient?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Here's the extended data and desired output:  serial # 4 has no Operation 10 so it's not complete.

Hope someone can help me.  Thank you.

Serial #Operation #Date completedCompleted? Op # 10-30 - Desired output
1101/2/2022Y
1201/3/2022Y
1301/5/2022Y
2101/8/2022Y
2201/10/2022Y
2251/12/2022Y
2301/14/2022Y
3101/5/2022N
3201/9/2022N
3251/12/2022N
4201/10/2022N
4251/11/2022N
4301/12/2022N

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