# Power Automate: Get the First N Items With take() and skip()

> For the full documentation index, see https://250highstreet.com/llms.txt

> Use take() to keep the first N items of an array and skip() to drop them. Combine both to get any slice, and learn the limits of each function.

Use take() in a Compose action. For example, take(variables('MyArray'), 3) returns the first three items as a new array. To drop the first items instead, use skip(variables('MyArray'), 3).

## What does take() do in Power Automate?

take() returns a new array that holds the first items of the original. It needs two values: the collection and the number of items to keep. The format is take(collection, count).

The original array does not change. The function also works on text, where it returns the first characters.

## How do you get the first 5 items from a list?

If the array has fewer than five items, you get all of them. Test this case before you rely on the result.

1.  Add a Compose action after the step that returns your array.
2.  Open the input and switch to the Expression tab.
3.  Enter take(outputs('Get_items')?\['body/value'\], 5), using the name of your own step.
4.  Choose Add, then save and run the flow.
5.  Read the Compose output in run history.

## What does skip() do?

skip() does the opposite of take(). It removes the first items and returns the rest. The expression skip(createArray('A','B','C','D'), 2) returns C and D.

A common use is to drop a header row from data that you read from a file.

## How do you get items from the middle of an array?

Combine the two functions. To keep items 3 to 5, write take(skip(variables('MyArray'), 2), 3). The inner skip() removes the first two items. The outer take() keeps the next three.

To get the largest or newest items, sort first. [The sort guide](/guides/power-automate-sort-array/) shows how. Then use take() on the sorted result.

## How do you remove the last item of an array?

No single function does this. Use take() with a calculated count: take(variables('MyArray'), sub(length(variables('MyArray')), 1)).

For how length() counts items, read [how to count items in an array](/guides/power-automate-count-items-in-array-length/).

## When should you use filter instead?

take() and skip() work by position. They do not look at the values. To keep items that match a rule, such as Status equals Open, use [the Filter array action](/guides/power-automate-filter-array/).

You can use both. Filter first, then take the first few results.

## How do you run a loop on only the first N items?

Put the take() expression in the input of the Apply to each action. The loop then runs only on those items.

To pull out one item and not a group, see [how to get the first item with first()](/guides/power-automate-get-first-item-from-array-first-function/).

## FAQ

### What is the syntax of take() in Power Automate?

take(collection, count). It returns a new array with the first count items.

### How do I skip the first row in Power Automate?

Use skip(array, 1). It returns every item after the first.

### How do I get items 3 to 5 of an array?

Write take(skip(array, 2), 3). Skip the first two items, then keep the next three.

### What happens if take() asks for more items than the array has?

You get the items that exist. Test with a short array to confirm.

## Sources

- [Power Automate: take Function (Manuel T. Gomes)](https://manueltgomes.com/microsoft/power-platform/powerautomate/powerautomate-function-reference/power-automate-take-function/)
- [Power Automate: skip Function (Manuel T. Gomes)](https://manueltgomes.com/microsoft/power-platform/powerautomate/powerautomate-function-reference/power-automate-skip-function/)
- [Reference guide to workflow expression functions (Microsoft Learn)](https://learn.microsoft.com/en-us/azure/logic-apps/workflow-definition-language-functions-reference)

## Related guides

- [Power Automate: Sort an Array With sort() and reverse()](/guides/power-automate-sort-array/)
- [Power Automate: Count Items in an Array with length()](/guides/power-automate-count-items-in-array-length/)
- [Power Automate Filter Array: Steps and Examples](/guides/power-automate-filter-array/)
- [Power Automate: Get the First Item of an Array With first()](/guides/power-automate-get-first-item-from-array-first-function/)

Source: https://250highstreet.com/guides/power-automate-take-skip-first-n-items-array/
