Power Automate Last Function Explained

Power Automate Last Function

The Power Automate Last function returns the last item of a given collection or the last character of a given string.

To find the first element or character, take a look at the Power Automate first function.

In this article, I’ll introduce you to the last function and will provide a step-by-step guide on how to use the function in a Microsoft flow.

Power Automate Last Function

power automate last expression
last expression in Power Automate

Return the last element from of an array or string.



Input parameters

  • collection (mandatory): The collection/string of which the last element/character should be returned.

Return value

  • Returns the last element/character of the given collection/string.

Power Automate Last Expression Example

=> 9

=> 'c'

How To Use The Power Automate Last Function

Follow the steps to use the Power Automate Last function in a flow.

  1. Create a new flow with trigger ‘Manually trigger a flow’

    Power Automate Last Function new flow

    New flow

  2. Add a new step by clicking on ‘+ New step’

    Power Automate Last Function new step

    Add a new step

  3. Search for ‘initialize’ and click on ‘Initialize variable’

    Power Automate Last Function initialize variable

    Add Initialize variable action

  4. Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[7,8,9]’

    Power Automate Last Function setup initialize variable

    Setup variable

  5. Add a compose step by searching for ‘compose’ and clicking on ‘Compose’

    Power Automate Last Function add compose step

    Add Compose action

  6. Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘last(variables(‘myArray’))’ 4) click on ‘OK’

    Power Automate Last

    Setup last expression in Power Automate

  7. Save and do a test run

    Power Automate Last Function test run result

    Result test run – Power Automate last function example

Leave a Comment

Your email address will not be published. Required fields are marked *