Power Automate Take Function Explained

Power Automate Take Function1

The Power Automate Take function allows you to select a specified number of items from the front of a collection.

The take function does the opposite of the skip function.

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

Power Automate Take Function

Power Automate Take expression
take expression in Power Automate

The Take function in Power Automate enables the extraction of a custom quantity of elements from the start of a collection.

Syntax

take('<collection>', <count>)
take([<collection>], <count>)

Input parameters

  • collection (mandatory): The collection that you want to retrieve items from the beginning.
  • count (mandatory): The number of items that should be retrieved from the beginning of the collection.

Return value

  • A string or array consisting of a specified number of elements taken from the beginning of the original collection.

Power Automate Take Expression Example

// take the first two elements
skip(createArray(1,2,3,4,5),2)
=> 1,2

// reference a variable in a take expression
skip(variables('myCol'),2)

How To Use The Power Automate Take Function

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

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

    Power Automate Take Function new flow

    New flow

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

    Power Automate Take Function new step 1

    Add a new step

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

    Power Automate Take Function initialize variable

    Add Initialize variable action

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

    Power Automate Take Function setup initlialize variable

    Setup variable

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

    Power Automate Take Function add compose step

    Add Compose action

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

    Power Automate Take

    Setup take expression in Power Automate

  7. Save and do a test run

    Power Automate Take Function test run result

    Result test run – Power Automate take function example

Leave a Comment

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