List.Last returns the last item in a list. Available in Excel (Power Query), Power BI Desktop, and Power BI Service.
If you want to grab the final value in a list, the last value in a column, or the last piece of a split-up string, this is the function you reach for.
Syntax of List.Last Function
List.Last(list as list, optional defaultValue as any) as any
where
list(required, list). The list you want the last item from.defaultValue(optional, any). The value returned whenlistis empty. Omit it and an empty list returnsnull.
Returns: the last item of the list, with its own type kept (text stays text, a number stays a number). If the list is empty, it returns defaultValue, or null when no default is given.
In plain terms, you hand it a list and it gives you back the item sitting at the very end.
Example 1: Get the last item of a list
Pull the final genre out of a short list.
let
Source = List.Last({"Mystery","Sci-Fi","Romance"})
in
Source
Result: Romance
Romance is the last item, so that is what comes back.
Example 2: Handle an empty list with no default
Ask for the last item of an empty list to see what happens.
let
Source = List.Last({})
in
Source
Result: null
An empty list has no last item, so List.Last returns null instead of throwing an error.
Example 3: Return a fallback value for an empty list
Pass a second argument so an empty list returns something readable instead of null.
let
Source = List.Last({},"No entries found")
in
Source
Result: No entries found
The list is empty, so List.Last returns defaultValue rather than null.
Example 4: Get the last value of a table column
Grabbing the last value of a column is where you will use this most.
Say you have an Invoices table with an InvoiceID and a Client column.
You want the most recently added invoice ID, which sits in the last row.
Here is the starting data:
| InvoiceID | Client |
|---|---|
| INV-90 | Northwind |
| INV-91 | Contoso |
| INV-92 | Fabrikam |
Pull the InvoiceID column into a list, then take its last item:
let
Source = Excel.CurrentWorkbook(){[Name="Invoices"]}[Content],
Result = List.Last(Table.Column(Source,"InvoiceID"))
in
Result
Table.Column turns the column into a list and List.Last returns its final value.
Result: INV-92
INV-92 is the value in the last row of InvoiceID.
Example 5: Get the last segment of split text
Split a file path on the backslash and keep only the file name at the end.
let
Source = List.Last(Text.Split("reports\2026\summary.xlsx","\"))
in
Source
Result: summary.xlsx
Text.Split breaks the path into a list of parts, and List.Last grabs the last one, which is the file name.
Things to keep in mind with List.Last
defaultValueonly fires for an empty list. A list whose last item isnullstill returnsnull, not the default. The default is purely the empty-list fallback.- “Last” means by position, not by value. It returns whatever sits at the end of the list, not the largest or the most recent. If you want the biggest value, sort the list first or use
List.Max. - It is the cheap alternative to positional access. Reaching the last item with
myList{...}needsList.Count(myList)-1and throws on an empty list.List.Lasthandles the empty case for you withnullor your default. - Pair it with functions that produce lists. It works well on top of
Text.Split(last segment of a path or string) andTable.Column(last value of a column), as in Examples 4 and 5. The same goes for any list you build withList.Transform.
Performance and query folding
List.Last does not fold to a database source, so the query runs locally. On a large foldable source, reading the last row this way pulls the whole column into memory first, which is slow. When the table is big, sort the source the other way and take the first row, or use Table.LastN.
Common questions about List.Last
What is the difference between List.First and List.Last?
List.First returns the item at the start of the list and List.Last returns the item at the end. Both take the same optional defaultValue for an empty list.
How is List.Last different from indexing with myList{...}?
myList{2} grabs a specific position by number and errors if that position does not exist. List.Last always targets the end and returns null or your default on an empty list, so you do not have to calculate List.Count(myList)-1 yourself.
List of All Power Query Functions
Related Power Query Functions / Articles: