Downloads
Power Query MList: pick and buildBeginner

List.First

Returns the first item in a list.

Syntax
List.First(list, optional default)

Returns: The first item, or the default when the list is empty.

What it does

List.First returns the item at the start of a list. Use it when the list is already in the order you want, for example the first transaction after a sort, or the opening balance from a list of month-end figures. If the list is empty, it returns the default you give, or null.

Syntax and arguments

Example

A fixed-asset register lists the depreciation for each period, starting with the first period. The reviewer needs the first value, and a message if the list is empty.

let
    DepreciationByPeriod = {1250, 1250, 1250},
    FirstCharge = List.First(DepreciationByPeriod, 0),
    NoCharge = List.First({}, "no periods")
in
    FirstCharge

FirstCharge is 1250. The second line shows the default at work: an empty list gives the text "no periods" instead of a null that could break a later step.

Example: a second, different use

Taking the earliest date after a sort: List.First(List.Sort(PaymentDates)) returns the first payment date in ascending order.

Things to watch

In business terms

Opening balances, first period charges, earliest transactions in a period and the first approver in a list are typical uses. State the order of the list in the notes, because "first" depends on the sort.

Related functions

All Power Query M functions · View as Markdown · M basics