Most history expressions require you to specify a time-expression, consisting of time units (
seconds, minutes, hours, days, or weeks) or an arithmetic expression. If the time interval is an arithmetic expression, G2 interprets its result as a number of seconds. Some examples of valid time-intervals are:
7 weeks, 6 days, 5 hours, 4 minutes, and 3 seconds
10 minutes
16 days and 2 hours
the current time + 10
3*4 seconds
between time-expression ago and time-expression ago phrase in these expressions, you must specify the longer time interval before the shorter time interval.
To obtain a history value:
the value of {variable | parameter}
{as of time-expression ago | as of integer-expression datapoints ago}
-> {integer | float | symbol | text | truth-value}
Two examples are:
![]() |
Specifying a time interval causes G2 to return the value from the specified time. If G2 did not collect a value then, it returns the value collected immediately prior to the specified time-interval. For instance, in the example shown here (
as of 1 hour ago), if no value were collected at that time, G2 would return the value collected before that time, perhaps 1 hour and 1 minute ago. If no previous time existed, G2 returns no value, expressed as **** (asterisks). Note that this behavior differs from the behavior of the interpolated value of expression. 0 - 9, and specifying 10 is invalid.
the value of the temperature of tank-3 as of 36 datapoints ago
Temperature attribute's 36th history value, the expression produces a no value condition.
To obtain the total number of history datapoints within, and on, the boundaries of the time interval you specify:
the number of history datapoints in {variable | parameter}
{during the last time-expression |
between time-expression ago and time-expression ago }
-> integer
Here are two examples:
![]() |
Computing the Average History Value
To compute the average history value over a specified period of time:
the average value of {quantitative-variable | quantitative-parameter}
{during the last time-interval |
between time-interval ago and time-interval ago}
-> float
The calculated average is the sum of the variable's or parameter's values divided by the number of values. G2 does not calculate a time-weighted average, in which the distribution of values over time can produce differing results.
Here are two examples:
![]() |
Tip: G2 does not compute a time-weighted average where the distribution produces differing results. This average value is simply the sum of the variable or parameter's values divided by the number of values.
Computing the Integral
To compute the integral over a selected period of time:
the integral in {seconds | minutes | hours | days | weeks}
of {quantitative-variable | quantitative-parameter}
{during the last time-interval |
between time-interval ago and time-interval ago}
-> float
Two examples are:
![]() |
G2 performs a true integration over time of the most recently received value for the variable or parameter at each instant of the specified time interval.
Computing the Interpolated Value
To compute the interpolated value of a variable or a parameter:
the interpolated value of {quantitative-variable | quantitative-parameter}
as of time-interval ago
-> float
If G2 did not collect a value for the variable or parameter at the time interval you specify, it performs straight-line interpolation of the values that were collected immediately before and after that time interval. For instance, if the expression states
1 hour ago and collections occurred at 50 minutes and 1 hour 5 minutes ago, G2 interpolates those two values. In this way, interpolation differs from the value of expression, which returns the value received prior to the specified time interval, if no value was received as of the specified time interval. Here is an example:
![]() |
Note: When obtaining interpolated values at a maximum time period value, it is possible for the value to not be returned. For example, if you keep history for 30 seconds, and then try to obtain the interpolated value of the variable as of 30 seconds ago, G2 returns no value.
Computing Maximum and Minimum Values
To compute the maximum or minimum value of a variable or a parameter over a period of time:
the {maximum | minimum} value of
{quantitative-variable | quantitative-parameter}
{during the last time-interval |
between time-interval ago and time-interval ago}
-> {integer | float}
Two examples are:
![]() |
Computing the Rate of Change
To compute the rate of change within a particular time unit over a time period:
the rate of change per {seconds | minutes | hours | days | weeks}
of {quantitative-variable | quantitative-parameter}
{during the last time-interval |
between time-interval ago and time-interval ago}
-> float
The expression calculates the rate of change per second, minute, hour, day, or week of the specified variable or parameter over the specified time interval. G2 calculates the rate of change by dividing the total accumulated change during the specified time interval by the length of the time interval.
Two examples are:
![]() |
G2 computes the rate of change by dividing the total accumulated change during the time period by the length of the time period.
Computing the Standard Deviation
To compute the standard deviation of the value over a selected period of time:
the standard deviation of {variable | parameter}
{during the last time-interval |
between time-interval ago and time-interval ago}
-> float
Two examples are:
![]() |