Amazon QuickSight
User Guide

The AWS Documentation website is getting a new look!
Try it now and let us know what you think. Switch to the new look >>

You can return to the original look by selecting English in the language selector above.

percentDifference

percentDifference calculates the percentage difference between the current value and a comparison value, based on partitions, sorts, and lookup index.

percentDifference is supported for use with analyses based on SPICE and direct query data sets.

Syntax

The brackets are required. To see which arguments are optional, see the following descriptions.

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

Arguments

measure

An aggregated measure that you want to see the percent difference for.

sort order field

One or more measures and dimensions that you want to sort the data by, separated by commas. You can specify either ascending (ASC) or descending (DESC) sort order.

Each field in the list is enclosed in {} (curly braces), if it is more than one word. The entire list is enclosed in [ ] (square brackets).

lookup index

The lookup index can be positive or negative, indicating a following row in the sort (positive) or a previous row in the sort (negative). The lookup index can be 1–2,147,483,647. For the engines MySQL, MariaDB and Aurora with MySQL compatibility, the lookup index is limited to just 1.

partition field

(Optional) One or more dimensions that you want to partition by, separated by commas.

Each field in the list is enclosed in {} (curly braces), if it is more than one word. The entire list is enclosed in [ ] (square brackets).

Example

The following example calculates the percentage of difference between the sum(Sales) for the current and the previous State, sorted by Sales.

percentDifference ( sum(amount), [sum(amount) ASC], -1, [State] )

The following example calculates the percent that a specific Billed Amount is of another Billed Amount, sorted by ([{Customer Region} ASC]). This example uses the revenue sample dataset, located in an Amazon S3 bucket. The fields in the table calculation are in the field wells of the visual.

percentDifference ( sum( {Billed Amount} ), [{Customer Region} ASC], 1 )

The following screenshot shows the results of the example. The red letters show that the total Billed Amount for the Customer Region APAC is 24 percent less than the amount for the EMEA region.

On this page: