Power Automate First Function Explained

Power Automate First Function

The Power Automate First function returns the first item of a given collection or the first character of a given string.

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

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

Power Automate First Function

Power Automate First expression
first expression in Power Automate

Return the first element from of an array or string.

Syntax

first('<collection>')
first([<collection>])

Input parameters

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

Return value

  • Returns the first element of the given collection or the first character of the given string.

Power Automate First Expression Example

first(createArray(7,8,9))
=> 7

first('john')
=> 'j'

How To Use The Power Automate First Function

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

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

    Power Automate First Function new flow

    New flow

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

    Power Automate First Function new step

    Add a new step

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

    Power Automate First 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 First Function setup initialize variable

    Setup variable

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

    Power Automate First 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 ‘first(variables(‘myArray’))’ 4) click on ‘OK’

    Power Automate First

    Setup first expression in Power Automate

  7. Save and do a test run

    Power Automate First Function test run result

    Result test run – Power Automate first function example

Leave a Comment

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