Table.Last

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

Returns 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:

BI Gorilla Youtube Channel

Last update: August 25, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/table-last
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.