The TIMESUM function aggregates values between two time periods and returns a single value.
The TIMESUM function aggregates values between two time periods and returns a single value.
For example, you can use the TIMESUM function to aggregate the revenue for previous periods through to the current period.
TIMESUM(Line item to aggregate [, Start period] [, End period] [, Aggregation method])
Argument | Data type | Description |
Line item to aggregate(required) | Number, Boolean, date, list, or text This argument must be a line item. |
The line item to aggregate over a period of time. This line item must have Time as a dimension. |
Start period | Number, date, time period | The period to start the aggregation from. This period is included in the aggregation. If omitted, the function aggregates all periods. |
End period | Number, date, time period | The end period to finish the aggregation at. This period is included in the aggregation. If omitted, the function only returns the value for the period in theStart periodargument. |
Aggregation method | Keyword | The aggregation method to use. The available keywords are SUM, AVERAGE, MIN, MAX, ANY, ALL, FIRSTNONBLANK, LASTNONBLANK, and TEXTLIST. There's more information below. The default behavior if omitted depends upon the data type of theLine item to aggregateargument. |
The TIMESUM function returns a result of the same data type as theLine item to aggregateargument.
Keyword | Compatible data types | Description |
SUM | Number | Returns the sum of the values. |
AVERAGE | Number | Returns the mean average of the values. |
MIN | Number, date | For numbers, returns the lowest value. For dates, returns the earliest value (a blank cell is considered to be as early as possible). |
MAX | Number, date | For numbers, returns the highest value. For dates, returns the latest possible date. |
ANY | Boolean | Returns a value of TRUE if any values of a Boolean-formatted line item are TRUE. |
ALL | Boolean | Returns a value of TRUE if all values of a Boolean-formatted line item are TRUE. |
FIRSTNONBLANK | Number, date, list, or text | Returns the first non-blank value for all data types. |
LASTNONBLANK | Number, date, list, or text | Returns the last non-blank value for all data types. |
TEXTLIST | Text | Returns all of the values of a text-formatted line item, separated by a comma and a space. |
TIMESUM(Revenue, -2, 0, SUM)
This formula sums the values for theRevenueline item from two periods before the current period through to the current period. This is inclusive of the start and end period.
The default aggregation method used when you omit theAggregation methodargument varies based on the data type of theLine item to aggregateargument. If the data type of theLine item to aggregateargument is:
TheStart periodandEnd periodarguments for the TIMESUM function define the period to aggregate values over. The TIMESUM function only returns a single value, the aggregated value over this defined range of periods. As a result, it's best to use the TIMESUM in a line item without theTimedimension to optimize module performance.
UseStart periodandEnd periodarguments with number, date, or time period data type values. You can use different data types for each argument.
For example, you can specify a time period for theStart periodargument, and 0 for theEnd periodargument. This aggregates values between the specified time period and the current period and updates automatically as the current period changes.
In Polaris:
In the Classic Engine:
In this example, there are two modules. The first module contains theTimedimension on columns, and theRevenueline item on rows. The module is namedRevenue 2021, which is referenced in later formulas.
TheCurrent Periodin this model, as defined inModel Settings > Time, isMay 21.
Jan 21 | Feb 21 | Mar 21 | Apr 21 | May 21 | Jun 21 | Jul 21 | Aug 21 | Sep 21 | Oct 21 | Nov 21 | Dec 21 | |
Revenue | 101,480 | 130,156 | 117,021 | 122,556 | 123,160 | 143,432 | 130,784 | 134,415 | 115,309 | 117,279 | 128,835 | 108,029 |
The second module contains only line items, which each contain formulas. These formulas highlight how you can use theStart periodandEnd periodargument to specify the period of aggregation.
The reason the formulas are in a separate module is because you should use TIMESUM in a module without theTimedimension to optimize performance.
Revenue for all periods
|
1,472,456 |
Revenue for 2 months ago
|
117,021 |
Revenue from 2 months ago to current period
|
362,737 |
Revenue for duration of Spring campaign
|
471,213 |
The first formula, in theRevenue for all periodsline item, uses only theRevenueline item for theLine item to aggregateargument. This means that the formula uses the default behavior for TIMESUM and sums all values in the module. This behavior can be useful when you useWeeks: GeneralinModel Settings > Time, as thisCalendar Typedoes not contain a summary of all periods.
The second formula, in theRevenue for 2 months agoline item, uses theRevenueline item for theLine item to aggregateargument. The formula uses-2for theStart periodargument. This means that the formula returns only the value from the period two periods before theCurrent Period, May 21. In this case, this is the value 117,021 from Mar 21.
In Polaris, this formula would aggregate all values from and including Mar 21 until the last period in the applicable time range.
The third formula, in theRevenue from 2 months ago to current periodline item, uses theRevenueline item for theLine item to aggregateargument. The formula uses-2for theStart periodargument and0for theEnd periodargument. This means that the formula sums the values from two periods before the current period, through to the current period. In this case, this is 362,737, the sum of the values for Mar 21, Apr 21, and May 21.
The fourth formula, in theRevenue for duration of Spring campaignline item, uses theRevenueline item for theLine item to aggregateargument. The formula uses references to theTimedimension for theStart periodandEnd periodarguments.Time.'Jan 21'andTime.'Apr 21'respectively. This means that the formula sums the values of theRevenueline item for and between these periods. As the formula uses references to theTimedimension, the values for the formula do not change as the current period in theModel Calendarchanges.
In this example, there are two modules. The first module contains theTimedimension on columns, and a number of line items on rows. The module is namedInitiative KPIs 2021, which is referenced in later formulas.
TheCurrent Periodin this model, as defined inModel Settings > Time, is Dec 21.
Jan 21 | Feb 21 | Mar 21 | Apr 21 | May 21 | Jun 21 | Jul 21 | Aug 21 | Sep 21 | Oct 21 | Nov 21 | Dec 21 | |
Revenue | 101,480 | 130,156 | 117,021 | 122,556 | 123,160 | 143,432 | 130,784 | 134,415 | 115,309 | 117,279 | 128,835 | 108,029 |
Promotion Active? | ||||||||||||
New product release date | 3/24/2021 | 4/30/2021 | 7/14/2021 | /10/15/2021 | 11/1/2021 | |||||||
Product name | Apple pie | Cinnamon swirl | Sugar donut | Lemon meringue pie | Mille-feuille |
The second module contains only line items, which each contain formulas. These formulas highlight the behavior of the different keywords for theAggregation methodargument. Each formula uses aStart periodof-2andEnd periodof0. This means that they apply to the values forOct 21,Nov 21, andDec 21.
The reason the formulas are in a separate module is because you should use TIMESUM in a module without theTimedimension to optimize performance.
Total revenue for last 3 months
|
354,143 |
Average revenue for last 3 months
|
118,048 |
Lowest revenue for last 3 months
|
108,029 |
Highest revenue for last 3 months
|
128,835 |
Promotion active last 3 months?
|
|
Promotion active for entirety of last 3 months?
|
|
First product release date in last 3 months
|
10/15/2021 |
Last product release in last 3 months
|
11/1/2021 |
Names of products released in last 3 months
|
Lemon meringue pie, Mille-feuille |
前四行项目包含德公式monstrate the behavior of the SUM, AVERAGE, MIN, and MAX keywords respectively. These aggregation methods can only be used with number-formatted values. For the values of Oct 21, Nov 21, and Dec 21, which are 117,279, 128,835, and 108,029, the formulas:
The fifth and sixth line items contain formulas that demonstrate the behavior of the ANY and ALL keywords respectively. These aggregation methods can only be used with Boolean-formatted values. For the values of Oct 21, Nov 21, and Dec 21, the formulas:
The seventh and eight line items contain formulas that demonstrate the behavior of the FIRSTNONBLANK and LASTNONBLANK keywords respectively. These aggregation methods can be used with number-, date-, list-, or text-formatted values. In this case, the line items contain dates that represent product release dates. For the values of Oct 21, Nov 21, and Dec 21, the formulas:
第九行项目包含一个公式,恶魔trates the behavior of the TEXTLIST keyword. This aggregation method can only be used with text-formatted values. The formula concatenates the values of Oct 21, Nov 21, and Dec 21, separating each value with a comma. It returnsLemon meringue pie, Mille-feuille.
Disclaimer
We update Anapedia content regularly to provide the most up-to-date instructions.