Skip to main content

direction

Returns the change direction for a series of numbers. Specifically, the function checks if the last value in a list or table region (e.g. a column) represents an increase or decrease relative to the first value.

The function returns one of these string values:

  1. 'up' — when the last value is greater than the first;

  2. 'down' — when the last value is less than the first; or

  3. 'stable' — when the first and last values are equal.

This function is often used with time-series data (e.g. a series of stock prices) to determine the general trend.

Parameters

  • X (list or table region)

    A list or table region of numbers.

Examples

The function can take a list of numbers.

ATL in Script

Result

[[myList = (1, 2, 3, 4); direction(myList)]]

up

[[myList = (4, 3, 2, 1); direction(myList)]]

down

[[myList = (4, 2, 3, 4); direction(myList)]]

stable

Using direction with table data

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

Month

Sales

Profit

Row 1

January

1,252,781.57

50,111.26

Row 2

February

1,046,028.91

48,263.78

Row 3

March

1,231,745.34

51,258.92

The function can take a column variable.

ATL in Script

Result

[[direction(Sales)]]

down

[[direction(Profit)]]

up

Note

In a "Describe Row in Context" project, the column variables are SalesColumn and ProfitColumn.