Table.Last

Updated on

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] )

Other functions related to Table.Last are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/table-last

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy