# Capsule averages, multiple per day

## Recommended Posts

Hi -

I am new to Seeq but have completed the Foundations course. I am trying to calculate the average of a signal over a 12 hour period. Since "Periodic -> Hours" only produces one capsule per day, I created 2 conditions, both Periodic -> Hours (12), with the second (\$Second12h) offset from midnight by 12 hours. I then was able to calculate the average with this formula, averaging the 12 hour averages

average(
\$signal.aggregate(average(), \$First12h, startkey()),
\$signal.aggregate(average(), \$Second12h, startkey())
)

Is there a more elegant way of doing this? I actually want to shrink down the periods to 6 hours or lower, so trying to see if I will need to create a large number of conditions (24/x conditions, where x is the length of the period in hours)

Thanks!

David Edelman.

##### Share on other sites

• Seeq Team

There's a periods() function in formula where you can do however long of time frames you want. For example periods(12h) or periods(6h). Or you can get even more complex if you (for example) want to do 12 hour time blocks, but every hour. Then from there, you can just average the signal during those time periods using Signal from Condition.

• 1
##### Share on other sites

• Seeq Team

Hi David - For this you can use the periods Formula.  You can also "anchor" it to a specific start time.  Example below.

`periods(12 hours, 12 hours, '2023-01-01T12:00:00','US/Mountain')`

• 1

## Create an account

Register a new account