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 Function
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.
-
Create a new flow with trigger ‘Manually trigger a flow’
New 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 ‘[1,2,3,4,5]’
Setup variable
-
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 ‘Expression’, 3) set expression to ‘take(variables(‘myCol’),2)’ 4) click on ‘OK’
Setup take expression in Power Automate
-
Save and do a test run
Result test run – Power Automate take function example