List.First
ListReturns the first item in a list, or a default value if the list is empty.
Syntax
List.First(list as list, optional defaultValue as any) as anyParameters
| Name | Type | Required | Description |
|---|---|---|---|
list | list | Yes | The list to get the first item from. |
defaultValue | any | No | The value to return if the list is empty. If omitted and the list is empty, an error is raised. |
Return Value
any — The 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 | |
|---|---|
| 1 | Alice |
Compatibility
✓ Power BI Desktop✓ Power BI Service✓ Excel Desktop✓ Excel Online✓ Dataflows✓ Fabric Notebooks