Skip to main content

median

Returns the median value for a set of numbers.

The input can be a list or table region (e.g. a column).

The median is the middle number in the set after sorting. If the set contains an even number of values, the function returns the average of the two middle values.

Parameters

  • INPUT LIST (list or table region)

    A list or table region of numbers.

  • IGNORE NULLS (Boolean)

    Optional. Whether to ignore null or empty values (true) or count them as a zero (false).

    Default: true

Examples

The function can take a list of numbers.

ATL in Script

Result

[[median((10, 2, 13, 4, 25))]]

10

Set the second parameter to false to count null values as zeros.

ATL in Script

Result

[[median((10, 2, 13, 4, 25, null))]]

10

[[median((10, 2, 13, 4, 25, null), false)]]

7

In the last example, the null is counted as zero, so the input set has six numbers. If the set contains an even number of values, the function returns the average of the two middle values.

Using median with table data

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

Branch

Orders

salesRev

COGS

otherRev

otherExp

netProfit

Row 1

Aberdeen

15

14,000

8,000

2,000

1,500

6,500

Row 2

Edinburgh

35

33,000

19,000

2,000

3,500

12,500

Row 3

Inverness

18

16,000

1,200

1,500

7,450

Row 4

Glasgow

35

32,500

17,750

1,250

1,700

14,300

The function can take a column variable.

ATL in Script

Result

[[median(salesRev)]]

24,250

Set the second parameter to false to count empty values as zeros.

ATL in Script

Result

[[median(COGS)]]

17,750

[[median(COGS, false)]]

12,875

Note

In a "Describe Row in Context" project, the column variables are salesRevColumn and COGSColumn.