/    /  Amazon QuickSight – percentDifference

Amazon QuickSight – percentDifference

 

The percentDifference function in Amazon QuickSight is used to calculate the percentage difference between a measure’s current value and a specified previous or following value. This function can be useful for comparing the growth or decline of a measure over time.

Syntax

#Start#
percentDifference
(
  measure 
 ,[ sortorder_field ASC_or_DESC, ... ]  
  ,lookup index
  ,[ partition_field, ... ] 
)
#End#

 

This function takes the following arguments:

 

  • measure: The measure field for which the percentage difference is to be calculated.
  • sortorder_field: (Optional) The field used for sorting the data.
  • ASC_or_DESC: (Optional) The sort order – ascending (ASC) or descending (DESC) – for the specified field.
  • lookup_index: (Optional) The number of rows to look back or forward to calculate the percentage difference.
  • partition_field: (Optional) The field used for partitioning the data.

 

 

Suppose you have a dataset that shows the monthly revenue for a company. You want to calculate the percentage difference in revenue between the current month and the previous month. You can use the percentDifference function as follows:

 

Example

#Start#
percentDifference(revenue, month ASC, 1)
#End#

 

This will calculate the percentage difference in revenue between the current month and the previous month, based on the ascending order of months. If you want to calculate the percentage difference between the current month and the following month, you can use -1 as the lookup_index. If you want to partition the data by a specific field – say, region – you can include the partition_field parameter.