## Rollups

Rollup statistics are quantized periods of data that return a desired statistic for that period of time. One example rollup operation would be to request the average point value for point 1 for the past day in 1 hour intervals. This would return 12 entries with the hourly average for each hour.

If no data is present in the period some statistics will be empty while others that depend on the pervious value to the period will not. When understanding the rollup statistics it is important to note that some statistics use one value prior and one value after the period if they are available. This continuous time effect is useful for charting and important to understand when doing analysis with the values.

**Note:** the REST api calls with rollups return the times for all values as the period start time. To get the actual times for every statistic one needs to use the statistics endpoint.

### Numeric Rollups

The following rollup types are available for Numeric data points:

**Note:** We've added new rollups. They are supported by all of our databases.

- Accumulator - The last value minus the previous value
- Average - The start value and all values within the period weighted by time
- Arithmetic_mean - The Average rollup is a time-weighted average and takes into account the “start value” of each period
- Count - The number of sampled or logged values within the period
- Delta - The change in point value within the period. 0 values and no start value: NaN, 0 values w/ start value: 0, 1 value with start value could be anything. 1 value with no start value delta 0
- First- The first sampled or logged value within the period
- Integral - The integral of the values during the period, taking into consideration the start value. The weighted sum of values by their durations
- Last - The last sampled or logged value within the period
- Maximum - The largest value of any values within the period, taking into consideration the start value
- Maximum_in_period - The original 'Maximum' rollup that includes the 'start value' of each rollup period
- Minimum - The smallest value of any values within the period, taking into consideration the start value
- Minimum_in_period - The original 'Minimum' rollup that includes the 'start value' of each rollup period
- Sum - The total of all values within the period, doesn’t count the start value unless the start value occurred exactly at period start.

### Non Numeric Rollups

The following rollup types are available for Alphanumeric, Binary and Multi-state points:

- Count - The number of sampled or logged values within the period
- First - The first sampled or logged value within the period
- Last - The last sampled or logged value within the period
- Mode - Most common value
- Runtime - The total time in this state
- Proportion - The proportion of time in this state to total time in any state (Not necessarily proportion of whole period)
- Starts - The number of occurrences of this state

## Statistics

Mango can provide statistics for a period of time, the group of statistics returned depends on the data type of the point.

### Starts And Runtime List

Binary and Multi-state points have these statistics to help understand the states that the point was in during the period.

- First - The first value sampled or logged in the period and the time it occurred
- Last - The last value sampled or logged in the period and the time it occurred
- Count - The count of values within the period
- Starts And Runtimes - A list of the states with the following statistics for each
- Runtime - The total time in this state out of all time in all states
- Proportion - The proportion of time in this state out of all time in all states
- Starts - The number of occurrences of this state

### Value Change Counts

Alphanumeric and Image data types have these statistics.

- First - The first value in the period and the time it occurred
- Last - The last value in the period and the time it occurred
- Count - The count of values within the period
- Changes - The number of changes in state during the period

### Analog Statistics

Numeric points have these statistics.

- Accumulator - The last value minus the previous value
- Average - The start value and all values within the period weighted by time
- Count - The number of sampled or logged values within the period
- Delta - The change in point value within the period. 0 values and no start value: NaN, 0 values w/ start value: 0, 1 value with start value could be anything. 1 value with no start value delta 0
- First- The first sampled or logged value within the period
- Integral - The integral of the values during the period, taking into consideration the start value. The weighted sum of values by their durations
- Last - The last sampled or logged value within the period
- Maximum - The largest value of any values within the period, taking into consideration the start value
- Minimum - The smallest value of any values within the period, taking into consideration the start value
- Sum - The total of all values within the period, doesn’t count the start value unless the start value occurred exactly at period start