Table.Last is a Power Query M function that extracts the last row of a table or an optional default value if the table is empty. The function returns the last row or the default value.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
Table.Last(
table as table,
optional default as any,
) as any
Description
Table.Last returns the last row or a specified default value. It provides the last row of the table
or an optional default value, default
, if the table is empty.
Examples
Find the last row of the table.
// Output: [CustomerID = 3, Name = "Paul", Phone = "543-7890"]
Table.Last(
Table.FromRecords( {
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
} )
)
Find the last row of the table ( {} )
or return [a = 0, b = 0] if empty.
// Output: [a = 0, b = 0]
Table.Last( Table.FromRecords( {} ), [a = 0, b = 0] )
Related functions
Other functions related to Table.Last are:
- Table.AggregateTableColumn
- Table.First
- Table.FirstN
- Table.FirstValue
- Table.LastN
- Table.Max
- Table.MaxN
- Table.Min
- Table.MinN
- Table.SingleRow
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy