# Description

Computes the sum of numbers within a fixed-size window moving along a Dimension List. For each item from given Dimension List, the sum is computed from all defined numbers within the considered window, blank values are ignored.

By default, if the input block is defined over a time dimension, the moving sum is applied over this dimension.

# Syntax

MOVINGSUM(input, window_size [, end_offset] [, dimension])

`input_block`

is the data source on which moving sum is computed, and must be an expression of Integer or Decimal type.`window_size`

is the size of the moving window (number of items considered). Must be above or equal to 1.`end_offset`

is the offset of the last item within the window relative to current one. This argument defaults to zero, meaning the window includes all items from`window_size - 1`

to current one. Default: 0.`dimension`

is the Dimension List along which the window is moving. This argument defaults to the time Dimension of input if there is exactly one, and must be explicitly specified otherwise. Default: a time dimension on which input_block is defined (Day, Month, Quarter or Year).

# Return type

Same than input data source, either Integer or Decimal.

# Example

Metric `SalesByEmployeeAndMonth`

defined on 2 dimensions (Month and Employee):

Jan | Feb | Mar | Apr | May | |
---|---|---|---|---|---|

Alice | 1 | 3 | 2 | 8 | |

Bob | 2 | 5 | 2 | 1 |

Formula = `MOVINGSUM(SalesByEmployeeAndMonth, 2)`

:

Jan | Feb | Mar | Apr | May | |
---|---|---|---|---|---|

Alice | 1 | 4 | 3 | 2 | 10 |

Bob | 2 | 7 | 7 | 3 | 1 |

Formula = `MOVINGSUM(SalesByEmployeeAndMonth, 3, 1)`

:

Jan | Feb | Mar | Apr | May | |
---|---|---|---|---|---|

Alice | 2 | 2 | 2.5 | 5 | 5 |

Bob | 7 | 9 | 9 | 3 | 1 |

Formula = `MOVINGSUM(SalesByEmployeeAndMonth, 2, 0, Employee)`

:

Jan | Feb | Mar | Apr | May | |
---|---|---|---|---|---|

Alice | 1 | 3 | 2 | 8 | |

Bob | 3 | 8 | 2 | 3 | 8 |

**See also**: MOVINGAVERAGE

## Comments

0 comments

Please sign in to leave a comment.