List.RemoveNulls

List

Removes all null values from a list, returning only non-null items.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

List.RemoveNulls(list as list) as list

Parameters

NameTypeRequiredDescription
listlistYesThe list from which null values should be removed.

Return Value

listA 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
Result
1{1, 3, 5}

Example 2: All nulls removed leaves an empty list

List.RemoveNulls({null, null, null})
Result
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
    Total
Result
Result
1750

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks