# Finding maximum value during the current time duration in a trend

Go to solution Solved by Kelly Kolotka,

## Recommended Posts

I'm looking to find the maximum value in a trend during the current time duration.  So, for instance, in an osculating trend of 6 hours, what would the maximum value be?  I also want to be able to use that value in a formula with another signal.  Right now, I am able to find the max value, but it says that it's scalar and can't be used in a formula.  I tired the .toSignal(), but that gives an error.

##### Share on other sites

• Seeq Team
• Solution

Hi Trevor,

There are multiple formulas you can write to accomplish this, but it will depend on the time duration you would like to find the maximum for. In the photo, I have found the maximum of my signal Temperature over 2 different time ranges. In this case, the dashed line is due to uncertainty in the calculation, but both formulas result in Signals.

1. max of 6 hour periods: This formula will find the maximum point in every 6 hour window: \$t.aggregate(maxValue(), periods(6hours), durationkey())

2. max of the last 6 hours: This will use now() so that the maximum is calculated for the past 6 hours relative to current time: \$t.aggregate(maxValue(), condition(6h, capsule(now()-6h, now())), durationkey())

##### Share on other sites

Thank you!  This helped out a lot