GROUPACCUMULATE
Syntax
GROUPACCUMULATE(<number or date>;<number>)
Description
Returns the sum of all previous records in a group.
This function requires a key column (GROUPBY) and two arguments. The first argument (OrderBy) is the column used for sorting the accumulated values. The second argument (number) is the column of values to be summed within their groups.
This is a group series function and only operates on columns from a data source or join sheet.
Example
Given the following data:
Date | Revenue |
---|---|
Jan 1, 2011 | 30 |
Feb 1, 2011 | 10 |
Mar 1, 2011 | 20 |
Apr 1, 2011 | 40 |
May 1, 2011 | 20 |
Jun 1, 2011 | 40 |
Jul 1, 2011 | 20 |
Aug 1, 2011 | 20 |
Sep 1, 2011 | 30 |
Oct 1, 2011 | 50 |
Nov 1, 2011 | 10 |
Dec 1, 2011 | 20 |
Jan 1, 2012 | 10 |
Feb 1, 2012 | 20 |
Mar 1, 2012 | 60 |
Jan 1, 2013 | 40 |
Feb 1, 2013 | 10 |
Mar 1, 2013 | 10 |
First create a group by the year using GROUPBY(YEAR(#RawData!Date))
Group_Year |
---|
2011 |
2012 |
2013 |
Next copy the date column to your group using COPY(#RawData!Date)
Group_Year | Date |
---|---|
2011 | Jan 1, 2011 |
2011 | Feb 1, 2011 |
2011 | Mar 1, 2011 |
2011 | Apr 1, 2011 |
2011 | May 1, 2011 |
2011 | Jun 1, 2011 |
2011 | Jul 1, 2011 |
2011 | Aug 1, 2011 |
2011 | Sep 1, 2011 |
2011 | Oct 1, 2011 |
2011 | Nov 1, 2011 |
2011 | Dec 1, 2011 |
2012 | Jan 1, 2012 |
2012 | Feb 1, 2012 |
2012 | Mar 1, 2012 |
2013 | Jan 1, 2013 |
2013 | Feb 1, 2013 |
2013 | Mar 1, 2013 |
Using GROUPACCUMULATE(#RawData!Date;#RawData!Revenue), Datameer returns the accumulated sum of all the records within each group.
Group_Year | Date | GROUPACCUMULATE returns |
---|---|---|
2011 | Jan 1, 2011 | 30 |
2011 | Feb 1, 2011 | 40 |
2011 | Mar 1, 2011 | 60 |
2011 | Apr 1, 2011 | 100 |
2011 | May 1, 2011 | 120 |
2011 | Jun 1, 2011 | 160 |
2011 | Jul 1, 2011 | 180 |
2011 | Aug 1, 2011 | 200 |
2011 | Sep 1, 2011 | 230 |
2011 | Oct 1, 2011 | 280 |
2011 | Nov 1, 2011 | 290 |
2011 | Dec 1, 2011 | 310 |
2012 | Jan 1, 2012 | 10 |
2012 | Feb 1, 2012 | 30 |
2012 | Mar 1, 2012 | 90 |
2013 | Jan 1, 2013 | 40 |
2013 | Feb 1, 2013 | 50 |
2013 | Mar 1, 2013 | 60 |