These cookies provide us with information on how our websites are being used, to help us improve the quality and relevance of content we place on them. Additionally, they also allow us to show you embedded videos and remember your preferences and actions, so that the websites do not bother you with the same request repeatedly (e.g. filling a form to download a PDF file and provide feedback about such actions to our affiliated entities).
You are viewing our older product's guide. Click here for the documentation of GoodData Cloud, our latest and most advanced product.
Functions For Referring to Past Time Periods
The following MAQL functions allow you to create metrics showing a time over time comparison (for example, month over month, or quarter over quarter) of past time periods:
Differences Between FOR Previous and FOR PreviousPeriod
The difference between the Previous( ) and PreviousPeriod( ) functions becomes clear when the date attribute in a report is smaller that the time period specified within the function’s parentheses.
FOR Previous( ) strictly follows the date attribute specified by the metric author within the parentheses of the function.
On the other hand, FOR PreviousPeriod( ) adapts to the context of the report at hand. Regardless of the date attribute specified by the metric author, the PreviousPeriod( ) function takes on the date attribute of the smallest granularity from the report.
In the following example, even though the metric in the final column has been defined as FOR PreviousPeriod(quarter)
, the function returns values from the previous month, as month is the most granular date attribute in this report.
Even if PreviousPeriod( ) automatically takes on the granularity of the smallest date attribute in a report, it is still important to specify a date attribute within the PreviousPeriod( ) function as a way of specifying the date dimension of interest. This is because projects often have multiple date dimensions, such as Date(Lead Created), Date(MQL Qualified), or Date(Snapshot).