List.Last

This function retrieves the final item from the given list. If the list is empty, it will return the defaultValue provided by the user. If no defaultValue is given and the list is empty, the function ...

Syntax

List.Last(list as list, optional defaultValue as any) as any

About

This function retrieves the final item from the given list. If the list is empty, it will return the defaultValue provided by the user. If no defaultValue is given and the list is empty, the function will return null.

Explanation

Retrieve the final value from a given list of numbers using the Power Query M function List.Last(). If the list is empty, the function will return -1 as the output. Example 1: Input: {1, 2, 3} Output: 3 Example 2: Input: {} Output: -1