Skip to main content

percentageChange

Calculates the percentage change between two numbers.

Parameters

  • NEW (number)

    The new value.

  • ORIGINAL (number)

    The original value.

  • DECIMAL PLACES (number or string)

    Optional. The number of decimal places for the result.

    You can set the default for this parameter in your project settings. If set to useNumberFormat, the number of decimal places is taken from your project's default number format pattern.

    Default: useNumberFormat

  • STRIP TRAILING ZEROS (Boolean or string)

    Optional. Whether to strip trailing zeros from the result (true) or leave them in place (false).

    You can set the default for this parameter in your project settings. If set to useNumberFormat, the decision to strip or retain trailing zeros is taken from your project's default number format pattern.

    Default: useNumberFormat

Important

The default values above are the system defaults. You can change these defaults in your project's Settings view. See Settings > Number and Currency for guidance.

Examples

Assume the settings in Settings > Number and Currency are:

Setting

Value

NUMBER FORMAT

#,##0.##

DECIMAL PLACES FOR PERCENTAGECHANGE

useNumberFormat

STRIP TRAILING ZEROS FOR PERCENTAGECHANGE

useNumberFormat

If the optional parameters are unspecified, the project settings apply.

ATL in Script

Result

[[percentageChange(10, 8)]]

25

[[percentageChange(10, 30)]]

-66.67

[[percentageChange(112, 99)]]

13.13

Use the third parameter to specify the number of decimal places.

ATL in Script

Result

[[percentageChange(112, 99, 0)]]

13

[[percentageChange(112, 99, 4)]]

13.1313

Note

Half-up rounding applies automatically.

Set the fourth parameter to false to include trailing zeros.

ATL in Script

Result

[[percentageChange(10, 8, 3)]]

25

[[percentageChange(10, 8, 3, false)]]

25.000

Using percentageChange with table data

Assume a "Describe the Table" project with this data:

Branch

Orders

Sales

Target

Row 1

Aberdeen

15

14,000

10,000

Row 2

Edinburgh

35

33,000

30,000

Row 3

Inverness

18

16,000

8,000

Row 4

Glasgow

35

32,500

35,000

Here's how you might use percentageChange with this data:

[[

totalSales = totalVal(Sales)

totalTarget = totalVal(Target)

changePct = percentageChange(totalSales, totalTarget, 1, false)

changeDirection = changePct > 0 ? 'exceeded' : 'fell short of'

joinStrings('Sales ', changeDirection, ' the target by ', abs(changePct), '%.')

]]  

The output text:

Sales exceeded the target by 15.1%.