Power Automate first() Function [With Various Scenarios]

Are you interested in learning about the Power Automate first() Function? If so, you’ve come to the right place. In this Power Automate tutorial, I will show what the Power Automate first() function is and its syntax.

Additionally, I will provide several scenarios to illustrate how to use the first() function in Power Automate.

  • Power Automate first() function using Instant cloud flow
  • Power Automate first() function using SharePoint List

In Power Automate, the first() function retrieves the first item from a given array or the first character from a given string.

Power Automate first() Function

The Power Automate first() function returns the first element or character of the given array or a string.

For example, there is an input array like [“Sam”, “Mathew”, “Peter”, “June”]. The first() function will retrieve the first element [Sam] from this array. Refer to the image presented.

Power Automate first() function

This is a brief introduction to the Power Automate first() function.

Power Automate first() Function Syntax

Below are the Power Automate first() function syntaxes:

first('<collection>')     // This is used for a given string to retreive the first character.

first([<collection>])    // This is used for an array to extract the first element.

Example:

first('Hello John! How are you?')  //    returns H

first(["Joe", "Lynne", "John"])  //          returns Joe

This is the Power Automate first() function syntax.

How to use the first() function in Power Automate

In this section, I will describe how to use the first() function in Power Automate with the different scenarios listed below.

Example 1: Power Automate first() function using Instant cloud flow

Let’s see how to use the first() function in Power Automate by creating the Instant cloud flow.

In this scenario, my goal is to extract the first element from the given array [“Sam”, “Mathew”, “Peter”, “June”]. The Power Automate first() function returns the first element “Sam” from the given array. Refer to the below image.

How to use first() function in Power Automate

To work around this, follow the steps below.

1. Navigate to https://make.powerautomate.com to open the Power Automate home page; click on + Create -> Select the Automated cloud flow -> Provide the flow name and choose your trigger’s flow (Manually trigger the flow).

2. To create and set the initial value, add the ‘Initialize variable’ flow action -> Set all the required details as shown below.

  • Name: Give the name of the initialized variable.
  • Type: Choose the type of the variable as Array.
  • Value: Here, I have given the “[“Sam”, “Mathew”, “Peter”, “June”] ” as the value of the initialized variable.
Power Automate first() function expression

3. Next, add the ‘Compose’ flow action to set the expression to extract the first element from the given array.

  • Inputs: Select field -> Select Expression -> Insert the first() function’s expression -> Click on OK.
first(variables('EnrolledCandidate'))

where,

  • first(): This is the first function applied to the collection to retrieve the first item from the collection.
  • variables() function is used to retrieve the value of a variable by its name.
  • EnrolledCandidate: Name of the initialized variable.
How to use first() function expression in Power Automate

4. Now, it’s time to Save and Test -> Click on Save and Test -> Then test it Manually. Then, the expand compose flow action will return the output as shown below.

Power Automate first() expression

This is how the Power Automate first() function works using Instant cloud flow.

Example 2: Power Automate first() function using SharePoint List

I will show how to use the first() function in Power Automate using SharePoint List.

For this, I have used a SharePoint list named “Events” with a few columns and their data types.

ColumnsData Types
Event NameSingle line of text
Event DescriptionMultiple lines of text
Event Date & TimeDate and Time
Event OrganizerPerson and Groups
How to use first() function format in Power Automate using SharePoint List

The Power Automate first() function retrieves the first character from the given string “Brand Brust Conference,” i.e. B. Refer to the image presented below.

Power Automate first() function using SharePoint List

To implement this, follow the steps below.

1. To initiate the process, access https://make.powerautomate.com. Once the Power Automate home page is opened, click on + Create -> Select an Automated Cloud Flow and assign a name to it -> Choose the trigger’s flow “When an item is created or modified” and click Create.

  • Provide all the required details for this trigger, as shown below.
    • Site Address: Provide the specific SharePoint site address.
    • List Name: Choose the name of the SharePoint List.
How to use the first() function in Power Automate using SharePoint List

2. Add the ‘Get item’ flow action to retrieve the particular information from a SharePoint list -> Set all the details as shown below.

  • Site Address: Select the specific SharePoint site address.
  • List Name: Provide the name of the SharePoint List.
  • Id: Select the SharePoint item ID from dynamic content.
Power Automate first() function expression using SharePoint List

3. Next, add the ‘Initialize variable’ flow action to create and set the initial value -> Provide all the required field values.

  • Name: Provide the SharePoint site address you plan to use.
  • Type: Choose the name of the SharePoint List.
  • Value: Select the item ID from dynamic content.
How to use first() function expression in Power Automate using SharePoint List

4. Then add the ‘Compose’ flow action to set the expression to extract the first character from the given string.

  • Inputs: Select field -> Select Expression -> Insert the first() function’s expression -> Click on OK.
first(variables('EventName'))

where,

  • first(): This is the first() function applied to extract the first item from the collection.
  • variable() function is used to retrieve the value of a variable by its name.
  • EventName: Name given to the initialized variable.
Power Automate first() expression using SharePoint List

5. Once the flow is created, click Save and Test -> Then test it Manually -> Then expand the compose flow action; it will showcase the output below.

How to use first() expression in Power Automate using SharePoint List

This is how the Power Automate first() function works using SharePoint List.

Conclusion

I hope this Power Automate tutorial helps you understand the first() function and syntax in Power Automate. Moreover, I have explained with different scenarios how to use the first() function in Power Automate. Like,

  • Power Automate first() function using Instant cloud flow
  • Power Automate first() function using SharePoint List

Also, you may like some more Power Automate tutorials: