Amazon QuickSight – periodOverPeriodDifference
The periodOverPeriodDifference function in Amazon QuickSight is used to calculate the difference between a measure’s values across different periods. It takes in four parameters: measure, date, period, and offset.
Syntax
#Start# periodOverPeriodDifference( measure, date, period, offset) #End#
This function takes the following arguments:
- measure: This parameter specifies the measure or metric that you want to calculate the difference for.
- date: This parameter specifies the date field that you want to use to group the data by periods.
- period: This parameter specifies the period of time that you want to use for comparison. It can be any of the following values: month, quarter, year, week, day, hour, minute, or second.
- offset: This parameter specifies the number of periods to offset the comparison. For example, an offset of -1 would compare the current period to the previous period.
Suppose you have a dataset with a Sales measure and a Date field that contains the date of each sale. You want to calculate the difference in sales between the current month and the previous month. You can use the periodOverPeriodDifference function as follows:
Example
#Start# periodOverPeriodDifference( Sales, Date, "month", -1 ) #End#
This will return the difference in sales between the current month and the previous month. If the current month has sales of $10,000 and the previous month had sales of $8,000, the function would return $2,000.