The following notes and examples provide insight into how rollups work with offsets and missing values. See History Rollups for a definition of the parameters described in these examples.
The RollupPeriod for a RollupType of Calculated Weighted Average tells the iterator how many days to include in each instance of the RollupUnit. If the RollupUnit is Days and the RollupPeriod is 2, there will be an entry for each day with the Calculated Weighted Average of the 2 days previous to that day rolled into the calculation.
The Offset for Calculated Weighted Average tells the iterator where to start iterating. For example:
6/4/2017 12:00:00.000
6/5/2017 12:00:00.000
6/6/2017 12:00:00.000
6/7/2017 12:00:00.000
6/5/2017 00:00:00.000
6/6/2017 00:00:00.000
6/7/2017 00:00:00.000
For all the rollups, the EarliestTime is not where the rollups start, but where the first rollup ends at — an EarliestTime of 6/5/2017 with an Offset of 0 means that the first rollup will go from 6/4/2017 00:00:00.000 to 6/5/2017 00:00:00.000.
The Offset DOES affect how many rollups appear for any given rollup. If you give an Offset of 9 and an EarliestTime of 6/5/2017 00:00:00.000 with a RollupPeriod of 1 day the iterator will try to match the times up by starting from 6/3/2017 09:00:00.000 - 6/4/2017 09:00:00.000 for the first rollup.
It does this because the 9 comes before midnight and it is trying to rollup to 9 so it has to go one extra day back. Think of it in terms of a timeline:
0__1__2__3__4__5__6__7__8__9__10__11__12__13__14__15__16__17__18__19__20__21__22__23__0
6/5/2017__________________________________ 6/6/2017
To roll up to 9 given an EarliestTime of 6/5/2017 00:00:00.000, the iterator goes back to the previous 9, which is 6/4/2017 09:00:00.000 and uses that as the start time. This means that it has to go back to 6/3/2017 09:00:00.000 and roll forward to 6/4/2017 09:00:00.000 for the first rollup value.
If you change the EarliestTime or LatestTime it could cause the rollups to go back further to start the rollup than you might expect depending on the Offset. This is because the EarliestTime is set as the end of the first RollupPeriod and if the end of the first RollupPeriod is not in line with the Offset then it could cause the calculation to go back further to look for a proper beginning point — this would mean, for a rollup with the following parameters:
| Parameters | Values | |
| RollupType: | Calculated Weighted Average | |
| EarliestTime: | 6/11/2017 15:59:59.999 | |
| LatestTime: | 6/12/2017 15:59:59.999 | |
| Offset: | 15 (3PM) | |
| RollupUnit: | Days | |
| RollupPeriod: | 1 |
The rollup will look at the Offset and time range and these will be the results:
The first rollup should end on 6/11/2017 15:00:00.000 and the EarliestTime is 6/11/2017 15:59:59.999.
6/11/2017 15:59:59.999 comes after 6/11/2017 15:00:00.000
There are more than 24 hours between (EarliestTime – (minus) 24 hours) and the EarliestTime so the first rollup will end on 6/11/2017 15:00:00.000. The second rollup will be from 6/11/2017 15:00:00.000 to 6/12/2017 15:00:00.00 with the LatestTime being after the Offset (15 is the unit and 15:59:59.999 is the time to stop). This means the rollup will go another record into the future and rollup from 6/12/2017 15:00:00.000 to 6/13/2017 15:00:00.000. The three records will then be:
6/11/2017 15:00:00.000
6/12/2017 15:00:00.000
6/13/2017 15:00:00.000
This example uses the following parameters:
| Parameters | Values | |
| RollupType: | Calculated Weighted Average | |
| EarliestTime: | 6/11/2017 15:59:59.999 | |
| LatestTime: | 6/12/2017 15:59:59.999 | |
| Offset: | 16 (4PM) | |
| RollupUnit: | Days | |
| RollupPeriod: | 1 |
The rollup will look at the Offset and time range and these will be the results:
The first rollup should end on 6/11/2017 16:00:00.000 and the EarliestTime is 6/11/2017 15:59:59.999.
6/11/2017 15:59:59.999 comes before 6/11/2017 16:00:00.000
There are fewer than 24 hours between (EarliestTime – (minus) 24 hours) and EarliestTime so the first rollup will end on 6/10/2017 16:00:00.000 because it has to go back an extra day to be able to rollup 24 hours’ worth of data and end right at the 16:00:00.000 mark. The second rollup will be from 6/10/2017 16:00:00.000 to 6/11/2017 16:00:00.00. The LatestTime being before the Offset (16 is unit and 15:59:59.999 is the time to stop). This means that the rollup will stop at the LatestTime just as you want it to, that is: 6/12/2017 16:00:00.000. The three records will then be:
6/10/2017 16:00:00.000
6/11/2017 16:00:00.000
6/12/2017 16:00:00.000
When the VHS goes to rollup values from a specific point in time to another specific point in time it uses a Hard Window to force a value to exist at the EarliestTime even if no value actually exist at the earliest time. The VHS carries over the last reported value at the time, and the iterator starts at exactly the point where EarliestTime specifies, taking into account the rules described above.
It is very important to remember that, the value found exactly at the EarliestTime will be included even if no history entry exists at that time. This means that for a RollupType such as Calculated Mean this will add one to the denominator.
For example, assume we have the following raw values:
| Value | Date and Time | |
| 1 | 01/13/2017 08:01:00.000 | |
| 5 | 01/13/2017 09:12:23.000 | |
| 10 | 01/13/2017 10:12:23.000 | |
| 100 | 01/14/2017 08:12:23.000 | |
| 1000 | 01/14/2017 20:16:31.000 |
And the iterator uses the following parameters:
| Parameters | Values | |
| RollupType: | Calculated Mean | |
| EarliestTime: | 01/14/2017 | |
| LatestTime: | 01/14/2017 | |
| Offset: | 9 | |
| RollupUnit: | Days | |
| RollupPeriod: | 1 |
We will see the following occur:
For Thin Rollup types (Thin Median, Thin Min/Max, and Thin Last), the iterator looks for values within each RollupPeriod. If no values are found within that RollupPeriod, the iterator thins the results by not rolling up that period. This results in RollupPeriods that are missing from the output.