Skip to content
Tutorials Center
My learning

Topics

Lesson 15 of 38 ยท Actions and Expressions

Arrays, Objects and JSON: Select, Filter array and Parse JSON

Handle lists and JSON in flows: Apply to each, Select, Filter array, Join, Create HTML table, Parse JSON, item() and first(), with runnable stand-ins.

Real data comes in lists: attachments, rows, replies, API results. Power Automate has a small set of Data Operation actions that reshape lists without writing a loop. Knowing them makes flows shorter, faster and cheaper, because one Select costs a single action while a loop costs one per item.

Arrays and objects

  • An object holds named values: {"name": "Ana", "age": 31}.
  • An array is an ordered list: [1, 2, 3] or a list of objects.
  • Most connector outputs are objects, and anything labelled value is usually an array.

Reading values in expressions:

TEXT
body('Get_items')?['value']                // the array of rows
first(body('Get_items')?['value'])          // first row
body('Get_items')?['value'][0]?['Title']    // title of first row
length(body('Get_items')?['value'])         // number of rows
item()?['Title']                            // current item inside a loop or Select

Create small arrays with createArray('a','b'), add with union(arr1, arr2), slice with take(arr, 3) and skip(arr, 3).

Apply to each

Use Apply to each when each item needs its own side effects (send an email, create a row). Otherwise use data operations, which run in one step.

Settings worth knowing: Concurrency control (parallel degree up to 50), and the loop's item is available as items('Apply_to_each') or item().

Select: reshape every item

Select takes a From array and a Map and returns a new array. In key-value map mode you define output property names and values:

Key Value
title item()?['Title']
total mul(item()?['qty'], item()?['price'])

Switch the Map to text mode (the toggle on the right) to produce an array of plain values, for example only the emails: item()?['email'].

Filter array: keep matching items

Filter array takes From and a condition built like a Condition card. It returns only items for which the condition is true, for example item()?['Status'] is equal to Open. In advanced mode write an expression: @and(equals(item()?['Status'], 'Open'), greater(item()?['Amount'], 100)).

Filter at the source with an OData Filter Query when you can, because Filter array first needs all rows retrieved.

Join, Create CSV table and Create HTML table

  • Join (Data Operation) turns an array into a string with a separator: names to Ana, Ben, Carla.
  • Create CSV table and Create HTML table turn an array of objects into a table. Choose Automatic columns or Custom to control headers and values. Put the HTML output into an email body to send a table.

Parse JSON

When an action returns JSON as plain text (for example the HTTP action's body), the flow does not know its fields. Parse JSON gives it a schema so that each field becomes dynamic content.

  1. Add Parse JSON (Data Operation).
  2. Content: the body to parse.
  3. Select Generate from sample, paste a typical response, and Power Automate writes the schema.
  4. Use the new tokens in later steps.

Edit the schema to make fields nullable ("type": ["string", "null"]) when the API sometimes returns null, otherwise the action fails on the first null.

Practising with stand-ins

The stand-ins use Python's list comprehensions to show what each action does to data.

Python Stand-in: Select, Filter array and Join

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Filter first, then Select: a Select over thousands of rows that you then discard wastes time.

Parse JSON in miniature

This stand-in parses a JSON string and reads fields safely, as the Parse JSON action allows. It also shows the null problem.

Python Stand-in: parse a JSON response and handle null

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Building an email table

A typical scheduled report: Get items with a filter query, Select to pick columns, Create HTML table, then Send an email (V2) with the table in the body. The Select and table steps replace a loop and string building and use two actions in total.

A stand-in for the HTML table step:

Python Stand-in: build an HTML table from an array

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Performance and limits

  • Apply to each over large arrays is slow and uses many actions; prefer Select, Filter array and bulk actions.
  • A connector returns a limited page of results (often 100 or 256 rows). Turn on Pagination in the action's Settings and set a threshold to retrieve more, up to the plan's limit.
  • Large arrays have size limits (for example 100 MB for message size, and different limits per connector), so process in batches if needed.
  • Use length() to check an array before you take its first item, because first() of an empty array is null.

Common mistakes

  • Using item() outside a loop or data operation.
  • Forgetting ?['value'] on a connector result, so the array is hidden one level deeper.
  • Using Apply to each to build an array by hand when Select does it in one step.
  • Parse JSON schemas that reject a null, which stops the flow.

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. Which action reshapes every item of an array into a new array?

    Select maps every item to a new shape and returns a new array.
  2. 2. What does Filter array do?

    Filter array returns the subset of items for which its condition is true.
  3. 3. Why use Parse JSON on an HTTP response?

    Parse JSON gives the flow a schema, so each property appears as a token.
  4. 4. How do you read the current element inside a Select map?

    item() returns the element being processed in Select, Filter array and loops.

Summary

  • Connector results are objects with value arrays; read them with ?['value'].
  • Use Select, Filter array, Join and Create HTML table instead of loops when you do not need side effects.
  • Parse JSON creates tokens from raw JSON; make schemas null-friendly.
  • Watch paging limits and array sizes.

Next: Connectors: standard, premium and custom