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
Return the first element from of an array or string.
- collection1 (mandatory): The collection or string of which the first element/character should be returned.
- 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.
Create a new flow with trigger ‘Manually trigger a flow’
Add a new step by clicking on ‘+ New step’
Add a new step
Search for ‘initialize’ and click on ‘Initialize variable’
Add Initialize variable action
Setup Initialize variable: 1) Provide a name, 2) select type Array, 3) Set value to ‘[7,8,9]’
Add a compose step by searching for ‘compose’ and clicking on ‘Compose’
Add Compose action
Setup compose action: 1) click into Inputs (popup appears), 2) click on ‘Expressions’, 3) set expression to ‘first(variables(‘myArray’))’ 4) click on ‘OK’
Setup first expression in Power Automate
Save and do a test run
Result test run – Power Automate first function example