List.RemoveNulls
ListRemoves all null values from a list, returning only non-null items.
Syntax
List.RemoveNulls(list as list) as listParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | The list from which null values should be removed. |
Return Value
list — A new list containing only the non-null items from the original list.
Remarks
List.RemoveNulls filters out all null values from a list, returning only non-null items. It is equivalent to List.Select(list, each _ <> null) but expresses intent more clearly.
This function is commonly used to clean a list before aggregating it, to prevent null propagation in calculations, or to filter the results of a lookup that returns null for unmatched items. For example, after using List.Transform to do a lookup, the resulting list may contain nulls for unmatched rows — List.RemoveNulls strips those out before passing to List.Sum or similar.
Non-null values including false, 0, and "" (empty string) are retained. Returns an empty list if all items are null. The original list is not modified. For counting how many items remain after removing nulls, use List.NonNullCount directly instead of removing nulls and counting.
Examples
Example 1: Remove null values from a mixed list
List.RemoveNulls({1, null, 3, null, 5})Result | |
|---|---|
| 1 | {1, 3, 5} |
Example 2: All nulls removed leaves an empty list
List.RemoveNulls({null, null, null})Result | |
|---|---|
| 1 | {} |
Example 3: Clean lookup results before summing
let
Lookups = {100, null, 250, null, 400},
CleanValues = List.RemoveNulls(Lookups),
Total = List.Sum(CleanValues)
in
TotalResult | |
|---|---|
| 1 | 750 |