Skip to main content

mode

Returns the mode for a set of values.

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

The mode is the value that appears most often in a set. If there are one or more mode values, the function returns a list. So, if there is only one mode value, the list will only have that one value. If there is no mode value, the function returns an empty list with a minor warning.

The second parameter controls how to handle null or empty values.

Parameters

  • INPUT LIST(list or table region)

    A list or table region of values. The values can be numbers, strings, Booleans, or datetime objects.

  • 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

[[mode((1, 4, 3, 4, 2))]]

4

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

ATL in Script

Result

[[mode((1, 4, 3, 4, 2, null, null))]]

4

[[mode((1, 4, 3, 4, 2, null, null), false)]]

4 and 0

In the last example, the nulls are counted as zeros, so the input set has two mode values (4 and 0). When there are one or more mode values, the function returns a list of those values.

Using mode 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

34

32,500

1,250

1,700

14,300

Row 5

Perth

15

15,000

8,000

2,000

1,500

7,500

The function can take a column variable.

ATL in Script

Result

[[mode(Orders)]]

15

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

ATL in Script

Result

[[mode(COGS)]]

8,000

[[mode(COGS, false)]]

8,000 and 0

Note

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