# New union capsule based on two different capsules

Go to solution Solved by Thorsten Vogt,

## Recommended Posts

I would like generate new capsules, grouped as -> start of capsules from first capsules until end of second capsules

When doing just a union \$c = \$a.union(\$b) the capsules in \$c are not getting grouped as needed.

thanks for any help

##### Share on other sites

• Seeq Team

Would recommend taking a look at the "join" option in Composite Condition under Identify - this will allow you to join from one condition to the next. You can see more visually in the skills explorer here under Identify Events >> Composite Conditions: https://skill-explorer.seeq.com/

##### Share on other sites

Thanks for the hint Joe, I checked the composite Condition but I still don´t figured out yet how to:

after rethinking I need to re-specify what I´m trying to achieve. On the same capsule layer, on the first found Capsule-1 extend the end of this Capsule-1

until the start of Capsule-2. Then again extend Capsule-3-end until start of Capsule 4 and so on.

To only make this on the capsule-pairs 1/2 3/4 5/6 ... maybe somehow count up?

##### Share on other sites

• Solution

Hello,

you might want to check the following way:

As you need to specify which is the first capsule you want to start with you need to define a bounding condition. In my example I use a monthly condition to do the calculation:

Next I created a signal that puts the value 1 at the start of each capsule:

`\$condition.removeLongerThan(40h).toSamples(\$c -> sample(\$c.startKey(), 1), 0s)`

This signal is used to build the running sum of these values:

The calculated value can be used to extend the original condition with a property containing the capsule number during each month:

`\$condition.removeLongerThan(1d).setProperty('Capsule Number', \$count, startValue())`

Then two new conditions can be created to include only capsules with odd and even capsule numbers:

`\$conditionWithCount.keep(\$c -> (\$c.property('Capsule Number')/2)-floor(\$c.property('Capsule Number')/2) > 0)`
`\$conditionWithCount.keep(\$c -> (\$c.property('Capsule Number')/2)-floor(\$c.property('Capsule Number')/2) == 0)`

A composite condition can be used to join the odd and even ones:

Hope this helps.

Regards,

Thorsten

##### Share on other sites

thanks alot works 👍