Site icon i2tutorials

Amazon QuickSight – Difference

Amazon QuickSight – Difference

 

The Amazon QuickSight difference() function is used to calculate the difference between the current value and a previous value for a given measure, based on the sort order and partitioning specified. This function can be used to calculate changes in data over time, among other applications.

Syntax

#Start#
difference(
    measure, 
    [ sortorder_field ASC_or_DESC, ... ],
    lookup_index,
    [ partition field, ... ]
)
#End#

 

This function takes the following arguments:

 

 

 

Example

#Start#
difference(SUM(Sales), [OrderDate ASC], 1, [Product])
#End#

 

This calculates the difference between the current row and the previous row for the “Sales” measure, sorted by “OrderDate” in ascending order, looking back 1 row, and partitioning by “Product”. This means that the difference is calculated separately for each unique combination of products, and is based on the difference in sales between the current row and the previous row.

 

Exit mobile version