List.Sum

Syntax

List.Sum(list as list, optional precision as nullable number) as any

About

Returns the sum of the non-null values in the list, list. Returns null if there are no non-null values in the list.

Example 1

Find the sum of a list of numbers.

Usage

List.Sum({1, 2, 3})

Output

6

Example 2

Compare calculating the sum of a list of numbers using double versus decimal precision.

Usage

let
    Values = {0.1, 0.2},
    DoubleSum = List.Sum(Values, Precision.Double),
    DecimalSum = List.Sum(Values, Precision.Decimal)
in
    [
        DoubleSum = DoubleSum,
        DecimalSum = DecimalSum
    ]

Output

[
    DoubleSum = 0.30000000000000004,
    DecimalSum = 0.3
]