List.Sum
List function · By Tahir Nas · Examples run in our simulator · Published · Updated
Adds the numbers in a list.
When to use it
Use it to total a list or a column (Table[Column]), and inside Table.Group aggregations. Nulls are ignored, but text values cause an error, so type the column first.
Syntax
List.Sum(list as list, optional precision as nullable number) as anyReturns
The sum, ignoring nulls.
Example
List.Sum({2, 5, null, 1})Result
8
Example: total a table column
Table[Column] is a list, so List.Sum can total it directly.
List.Sum(#table({"Region", "Rep", "Amount"}, {{"North", "Ana", 120}, {"South", "Bo", 80}, {"North", "Cy", 200}, {"South", "Ana", 50}})[Amount])Result
450
Both results are produced by the Power Query Exercises simulator, an independent implementation of a documented subset of M, and checked on every build.
Good to know
- Combine with Table[Column] to sum a column.
Common mistakes
- Summing a column that is still text.
- Expecting an empty list to give 0: it gives null.
Exercises that use List.Sum
- beginner~10 minFree
Clean and summarize a sales export
Trim messy region names, keep valid completed orders, remove an exact duplicate and total revenue by region.
- intermediate~7 minFree
Fix a step that silently skips the cleaning step (kite shop)
The query runs, but its totals are split across " north" and "North": the Group step reads Source instead of the cleaned step.
- intermediate~8 minPro
Summarise orders by region (kite shop)
Group by Region with order count, total quantity and average unit price, sorted by region.
- intermediate~9 minPro
Build a one-row summary table in M (kite shop)
Write a let expression that computes order count, total quantity and the largest unit price, returned as a one-row table.
- advanced~10 minPro
Show each region's share of total revenue (kite shop)
Total revenue per region, then each region's percentage of the grand total.
- advanced~11 minPro
Summarise each customer's orders without multiplying rows (florist)
Join customers to their orders but keep one row per customer, with the number of orders and total quantity.
Learn more
- M basics: let, records and lists lesson
- Group by with several aggregations lesson
- Group By recipes: count if, concatenate, first and last, top value guide
Related functions
Official documentation: List.Sum on Microsoft Learn.