periodOverPeriodDifference
The periodOverPeriodDifference
function calculates the difference of a measure over two different time periods as specified by period granularity and offset. Unlike a difference calculation, this function uses a date-based offset instead of a fixed sized offset. This ensures that only the correct dates are compared, even if data points are missing in the dataset.
Syntax
periodOverPeriodDifference( measure, date, period, offset)
Arguments
- measure
-
An aggregated measure that you want to perform the periodOverPeriod calculation on.
- dateTime
-
The Date dimension over which we are computing Period-Over-Period calculations.
- period
-
(Optional) The time period across which you're computing the computation. Granularity of
YEAR
meansYearToDate
computation,Quarter
meansQuarterToDate
, and so on. Valid granularities includeYEAR
,QUARTER
,MONTH
,WEEK
,DAY
,HOUR
,MINUTE
, andSECONDS
.The defaults value is the visual date dimension granularity.
- offset
-
(Optional) The offset can be a positive or negative integer representing the prior time period (specified by period) that you want to compare against. For instance, period of a quarter with offset 1 means comparing against the previous quarter.
The default value is 1.
Example
The following example calculates the month over month difference in sales with the visual dimension granularity and default offset of 1.
periodOverPeriodDifference(sum(Sales), {Order Date})
The following example calculates the month over month difference in sales with a fixed granularity of MONTH
and fixed offset of 1.
periodOverPeriodDifference(sum(Sales),{Order Date}, MONTH, 1)
