# Create an event counter

## Recommended Posts

I need to creat an event counter to calculate how many regenerations we're having in our columns.

I already have an event counter for regenerations, but I'd like this counter to reset on each 3 events, because after 3 regenerations we need to do a clean up, and also I'd like to keep it register and show when clean up should be done.

##### Share on other sites

• Seeq Team

Hi Marcelo,

I am not certain I understand but I think you want to count the number of regenerations in between each "cleanup". If this is the case then you likely need to define a condition for when "cleanups" actually occur, and then you can create a condition for "time in between cleanups" using the .inverse() Formula function (there are several relatively easy you might find the "time in between cleanups"). Once you have the condition for "time in between cleanups", then a runningSum() Formula function would be one way to count the current number of regenerations.

I'm happy to try to help iterate with your solution here on the forum, but because I'm not certain about the calculations you want to do, the most efficient way to get a solution for your questions would be to sign up for an upcoming Seeq Office Hours where you can share your screen and get help: https://info.seeq.com/office-hours

John

• 1
##### Share on other sites

• 2 weeks later...

Well... I will try to clarify!

First of all, I need to count regenerations, 3 by 3.
After 3 regenerations should be done a clean up.

The reason for this calculation is to understand if this pattern is really being followed and to also predict when the next one will be. In parallel we have this condition that indicates when there is a clean up. So we're going to follow both of them.

##### Share on other sites

• Seeq Team

Hi Marcelo,

I'll add a few suggestions below, but I would most recommend you sign up for an upcoming Seeq Office Hours where you can work through the calculations with a Seeq Analytics Engineer: https://info.seeq.com/office-hours

If you simply want to count regenerations, you could do a running sum of your regeneration signal over a specified time period or a Periodic Condition. If you want to break the sum into groups of 3, you could divide the running sum by 3 and look for time periods where the result is an integer.

If you already have a cleanup condition, it would be easy to identify all the cleanup events (capsules) when a cleanup is performed and the number of regenerations just before the cleanup is not equal to 3. You could do this by doing a running sum of regenerations based on a condition that is the time between cleanups (which would be \$Cleanups.inverse()).

It is also possible that the Formula functions below may be useful to you, as they allow you to focus on a specific number of recent sample values or capsules.