Jump to content

Join Capsules by Matching Capsule Properties


Recommended Posts

  • Seeq Team

Use Case Background

Batch operations may be characterized by two conditions. The first condition represents the start of the batch and the second condition contains the end of the batch. Each capsule has the batch ID as a capsule property. The goal is to make a single condition that represents the duration of the batch by joining the start and end conditions.

Solution 1 - Simple Join

If the batches are orderly and the end of one batch does not overlap with the start of the next batch, then using the Join logic in the Composite Condition tool is the easiest option.

image.png

However, if the end of one batch overlaps with the start of another, then some batches may not be joined. In the screenshot below the third batch on June 6 is not joined.

image.png

 

Solution 2 - Use Formula to join based on matching the batch ID capsule property

By using a transform in Formula all the batches in this scenario can be joined. In addition the batch ID property is assigned to the new capsules.

image.png

Here is the Formula used to do this...

Variables

Name Item Type
$startCond Start Condition Condition
$endCond End Condition Condition

Formula

//Define the max time into the future to look for the end capsule
$lookAheadTime = 2d

//Resize the starting capsule to extend for the druation of the look ahead time
$startCond.move(0s,$lookAheadTime)

//Use a transfrom to take each start capsule and look for a matching end capsule and join by making a new capsule
.transform(
  $startCap -> capsule($startCap.getStart(),  //Get the start key for the capsule

     //Filter the end condition based on BatchID
     //Find the specific capsule by in the filtered condition using toGroup($startCap).first()
     //We can look for the first capsule because we only expect to find one capsule in the condition 
     //Get the end key for the capsule using .getEnd()
     $endCond.filter($endCap -> $endCap.getProperty('BatchID') == $startCap.getProperty('BatchID')).toGroup($startCap).first().getEnd())

     //Assign the property of the starting capsule to the new capsule
     .setProperty('BatchID', $startCap.getProperty('BatchID'))

     , $lookAheadTime)

 

Edited by Krista Novstrup
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...