FOR Previous

By default, the FOR Previous function refers to values from one time period ago. You can customize FOR Previous by adding a second parameter to the function.

For differences between FOR Previous and FOR PreviousPeriod, see Functions For Referring to Past Time Periods.


SELECT … FOR Previous(…,…)
SELECT metric FOR Previous(time_attribute)
SELECT metric FOR Previous(time_attribute, #periods_ago)


SELECT Revenues FOR Previous(Quarter)

By default, FOR Previous()refers to values from one time period ago. This can be customized by adding a second parameter to the function. For example, you may want to return a revenue value from three quarters ago (see below).

SELECT Revenues FOR Previous(Quarter , 3)

Note how the Previous Qtr column in the table below displays a metric that is linked to the metric values in the Amount column with the FOR Previous( ) function.

Column 3 and column 2 metric values are linked with the For Previous(quarter) function

Payment FOR Previous(Quarter,2) refers to the payment from two quarters ago

Even in cases where metric values are broken across a date attribute of smaller time granularity, the GoodData Platform intelligently calculates FOR Previous(quarter) metric values. In the case illustrated below, each month in a quarter is linked to the corresponding month in the previous quarter.

Metric values in column 4 are related to column 3 values using the For Previous(quarter) function. Note how the GoodData Platform intelligently interprets FOR Previous(quarter) by associating each month within a quarter to the corresponding month in the previous quarter

To be able to use FOR Previous to compare data to the same period of the last quarter/year when filtering by weeks, do the following:

  1. Switch the version of the Extensible Analytics Engine (see XAE - Extensible Analytics Engine) to 3.
    To do so, set the xae_version platform setting to 3 (see Configure Various Features via Platform Settings).
  2. Migrate the Date datasets in your project to the urn:custom_v2:date date dimension.
    To do so, see "Migrate from a Legacy Date Dimension to urn:custom_v2:date" in Custom Calendars - Self Service.

Powered by Atlassian Confluence and Scroll Viewport.