Smart Systems for Home

Plain how-to guides for smart home, security and home Wi-Fi

Power Query List.Sum: Step-by-Step Guide

· 5 min read · Home Tech

In this article
  1. What You'll Need
  2. Step-by-Step
  3. Common Mistakes
  4. Tips
  5. Troubleshooting
  6. Frequently Asked Questions

List.Sum in Power Query adds up all the numbers in a list and returns a single total. You use it inside the Power Query Editor when you need to aggregate values from a column, a set of columns, or a list you have built with other functions. The basic syntax is List.Sum(list as list, optional precision as nullable number) as any. The first argument is the list of numbers; the optional second argument controls precision (rounding) for decimal calculations. If the list is empty, List.Sum returns null. If the list contains non-numeric values, it returns an error unless you clean or transform the list first.

What You'll Need

  • Power BI Desktop, Excel (Power Query is built into Excel 2016 and later), or another tool that hosts Power Query.
  • A data source loaded or connected in Power Query Editor.
  • Basic familiarity with the Power Query Editor interface: the ribbon, the Queries pane, and the formula bar.

Step-by-Step

  1. Open Power Query Editor. In Excel, go to the Data tab and click Get Data > Launch Power Query Editor (or edit an existing query). In Power BI Desktop, click Transform Data on the Home ribbon. Menu labels can differ slightly by version and platform.
  2. Load or select your data. Choose the query that contains the numbers you want to sum. If you need to sum values from multiple columns, you will first need to create a list from those columns.
  3. Decide where the result should go. List.Sum returns a scalar value, so you typically use it in a custom column, a calculated table, or as part of a larger expression. For a quick total of a single column, you can use the Transform tab > Statistics > Sum button, which writes the List.Sum expression for you.
  4. Write the List.Sum expression. In the formula bar, type = List.Sum( and then reference your list. For example, if your query has a column named Sales, and you want to sum that column, the expression is = List.Sum(#"Changed Type"[Sales]) (the step name may differ). To sum multiple columns, build a list first: = List.Sum({[Sales], [Returns], [Adjustments]}).
  5. Handle nulls and errors. List.Sum ignores null values but errors on text or other non-numeric types. If your column may contain nulls, you can leave them; if it may contain text, clean the column first (for example, replace errors or filter out non-numeric rows) or use List.Sum(List.Transform(list, each try Number.From(_) otherwise null)) to coerce values safely.
  6. Apply the step. Press Enter or click the checkmark in the formula bar. The result appears as a new step in the Applied Steps pane. If you used a custom column, the new column will contain the same total on every row; if you used a calculated table or a query that returns a single value, you will see one row with the total.
  7. Verify the result. Compare the total with a manual sum or with the Statistics > Sum output. Check that the step references the correct column and that no filters were applied unintentionally.

Common Mistakes

  • Passing a table instead of a list. List.Sum expects a list, not a table. Use Table.Column(table, "ColumnName") or the column reference syntax TableName[ColumnName] to get a list.
  • Forgetting that List.Sum returns null for an empty list. If your list can be empty, wrap the result with ?? 0 (the coalesce operator) to return zero instead of null.
  • Including non-numeric values. Text, dates, or logical values cause an error. Clean or transform the list before summing.
  • Using the wrong step reference. If you rename a step or column, the expression may break. Use the Applied Steps pane to confirm the exact names.
  • Expecting List.Sum to work on a column with mixed types. Power Query may infer the column as Any; change the data type to a numeric type first.

Tips

  • Use the Statistics > Sum button for a quick total of a single column; it writes the correct List.Sum expression for you.
  • To sum a list of lists (for example, multiple columns), combine them with List.Combine before summing: List.Sum(List.Combine({list1, list2})).
  • For decimal precision, pass the optional precision argument: List.Sum(list, Precision.Double) or Precision.Decimal. This controls rounding behavior.
  • If you need to sum values conditionally, filter the list first with List.Select or List.Transform.
  • Remember that List.Sum is case-sensitive for column names; match the exact name in the query.

Troubleshooting

If List.Sum returns an error, check the following in order:

  1. Error: "We cannot convert the value null to type List." The argument is null, not a list. Ensure the column reference returns a list. If the column is empty, handle nulls with ?? {} before summing.
  2. Error: "We cannot convert a value of type Table to type List." You passed a table. Use Table.Column or the column reference syntax to get a list.
  3. Error: "We cannot convert a value of type Text to type Number." The list contains text. Clean the column or use List.Transform with Number.From to convert.
  4. Result is null. The list is empty. Use ?? 0 to return zero.
  5. Result is wrong. Check for filters applied before the step, or for duplicate values. Also verify that the column reference points to the intended step.
  6. Formula bar is not visible. Enable it from the View tab in Power Query Editor.

If the expression still fails, simplify it: test List.Sum on a small hard-coded list like {1,2,3} to confirm the function works, then build up to your actual list.

Frequently Asked Questions

What does List.Sum do in Power Query?

It returns the sum of all numbers in a list. It is the Power Query equivalent of summing a column.

Can List.Sum handle null values?

Yes, it ignores nulls. If the entire list is null or empty, it returns null.

How do I sum multiple columns with List.Sum?

Create a list of the column values using {[Column1], [Column2]} and pass that to List.Sum. Or use List.Combine to merge lists first.

Why does List.Sum return an error for my column?

The column likely contains non-numeric values. Change the column data type to a number or clean the values before summing.

What is the precision argument in List.Sum?

It is an optional parameter that controls rounding for decimal numbers. Use Precision.Double or Precision.Decimal.

Can I use List.Sum in a custom column?

Yes, but the result will be the same total on every row. For row-level sums, use the addition operator instead.