List.First

List

Returns the first item in a list, or a default value if the list is empty.

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

Syntax

List.First(list as list, optional defaultValue as any) as any

Parameters

NameTypeRequiredDescription
listlistYesThe list to get the first item from.
defaultValueanyNoThe value to return if the list is empty. If omitted and the list is empty, an error is raised.

Return Value

anyThe first item in the list.

Remarks

List.First returns the first item from a list. Provide a default value to handle empty lists gracefully instead of raising an error. This is commonly used inside Table.Group aggregations — for example, each List.First([Product]) to get the first product in each group.

Examples

Example 1: Get the first customer name

let
    FirstCustomer = List.First(Table.Column(Sales, "CustomerName"))
in
    #table({"FirstCustomer"}, {{FirstCustomer}})
Result
FirstCustomer
1Alice

Compatibility

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