List.Last Function in Power Query
The List.Last function returns the last item in the list, and an optional default value if the list is empty. If the list is empty and a default value is not specified, the function returns null.
Syntax
List.Last( list as list, optional defaultValue as any ) as any
Example: Find the last item in the list.
Power Query M
let Source = {"India", "America", "Canada", "Japan", "Australia", "England"}, Return = List.Last(Source) in Return
The output of the above code is England.
Example: If the list is empty default value is returned if specified otherwise null returned.
Power Query M
let Source = {}, Return = List.Last(Source, "Empty List") in Return
The output of the above code is "Empty List".