# Finding Periods of Overlapping Events

## Recommended Posts

• Seeq Team

FAQ: How do I identify time periods where I have overlapping capsules within the same condition? I may want to keep only the capsules (time periods) where capsules overlap. I may also want to keep the times where a certain number (2, 3, or more) of capsules overlap. In this example, we will find time periods where there are at least 2 overlapping capsules which make up the Event Condition. In the screenshot below, you can see there are 3 separate time periods where the Event condition capsules overlap:

Step 1: Merge any overlapping capsules together using the merge() function in Formula:

Now, we have a time period basis (Event Condition (merged)) over which we can count the total number of overlapping capsules.

Step 2: Count the number of overlapping capsules using the count of the original Event Condition capsules over each Event Condition (merged) capsule:

This creates a new signal as shown in the trend below. We can see that the new signal values (where > 1) correctly identify the 3 time periods where there are overlapping capsules in the original Event Condition.

Step 3: We use Formula to find where the Event Condition (merged) capsules touch a time period where the Number of Overlapping Events signal (created in Step 2) is > 1. Note that we could test for varying number of overlapping capsules (> 2, > 3, etc.) depending on the goals of our analysis. We could also break Step 3 into 2 steps (a Value Search to find where the Number of Overlapping Events is > 1, followed by a Composite Condition to do the touches logic). This generates the final results where the Overlapping Events condition correctly identifies our time periods of interest:

• 2
##### Share on other sites

• Seeq Team

As another variation, in some cases the user may want to see the number of overlapping capsules at any point in time. In this case, the .fragment() Formula function may be helpful:

\$EventCondition.fragment()

The .fragment() function creates a non-overlapping condition representing all the boundaries of capsules in an overlapping condition.

You can see a comparison of the conditions generated using .merge() and .fragment() below. Where there are overlapping capsules, the .fragment() function creates a series of capsules touching each other. For example, note that there are 5 green capsules in the Event Condition (fragment) shown on the far right of the trend.

• 1