Use data operations

In this article, you learn about some common data operations in Power Automate, such as compose, join, select, filter arrays, create tables, and parse JSON. Use these operations to manipulate data when you create flows.

Note

The different sections in this article aren't related and aren't dependent upon each other. The different sections use different examples.

Here's a quick video about data operations.

Prerequisites

  • Access to Power Automate.
  • A tool to send HTTP POST requests with a JSON array to your flow.

Use the compose action

Use the Data Operation - Compose action to save yourself from having to enter the same data multiple times as you're designing a cloud flow. In this example, you need to enter an array of digits—[0,1,2,3,4,5,6,7,8,9]—several times while you design your flow. You can use the compose action to save the array, as described in the following procedure.

  1. Search for compose, and then select the Compose - Data Operation action.

Screenshot of searching for and selecting the Compose action.

  1. In the Inputs box, enter the array that you want to reference later.

    Screenshot of configuring the compose action.

Tip

To make the Compose card easier to find later, rename it by selecting the text Compose on the title bar of the card and entering a name that's easy to remember.

When you need to access the contents of the compose action, do so by following these steps.

  1. Add an action, such as Join - Data Operation.

  2. Select the control to which you'd like to add the contents you saved in the compose action.

    The Add dynamic content from the apps and connectors used in this flow screen opens.

  3. On the Dynamic content tab, in the Compose section, select Outputs.

    Screenshot of using Outputs from the Compose action.

Use the join action

Use the Data Operation - Join action to delimit an array with the separator of your choice. For example, your flow receives a web request that includes the following array of email addresses: ["d@example.com", "k@example.com", "dal@example.com"]. However, your email program requires addresses to be formatted in a single string, separated with semicolons. You use the Data Operation - Join action to change the comma delimiter (,) to a semicolon (;) by following these steps:

  1. Add a new action, search for Join, and then select Data Operation - Join.

    Screenshot of searching for and selecting the join action.

  2. In the From box, enter the array, and in the Join with box, enter a semicolon (;).

    Screenshot of configuring the join action.

  3. Save your flow, and then run it.

  4. After your flow runs, the output of the Data Operation – Join action will be a string with the addresses joined by semicolons, as shown in the following screenshot.

    Screenshot of input of addresses separated by commas, a Join with value of semicolon, and output of those addresses separated by semicolons.

Use the select action

Use the Data Operation – Select action to transform the shape of objects in an array. For example, you can add, remove, or rename elements in each object in an array.

Note

Although you can add or remove elements by using the select action, you can't change the number of objects in the array.

In this example, data enters your flow via a web request in this format:

[ { "first": "Eugenia", "last": "Lopez" }, { "first": "Elizabeth", "last": "Moore" } ]

You want to reshape the incoming data by renaming first to FirstName and last to FamilyName, and adding a new member named FullName that combines first and last (separated with a space).

[ { "FirstName": "Eugenia", "FamilyName": "Lopez", "FullName": "Eugenia Lopez" }, { "FirstName": "Elizabeth", "FamilyName": "Moore", "FullName": "Elizabeth Moore" } ]

To do this:

  1. Add the When an HTTP request is received trigger to your flow.

  2. Select Use sample payload to generate schema.

    Screenshot of selecting the sample payload.

  3. In the box that appears, paste a sample of your source data array, and then select Done.

  4. Add the Data Operation – Select action, and then configure it as shown in the following screenshot.

    Configure the select action.

    > The output from the select action is an array that contains the newly shaped objects. You can then use this array in any other action, such as the compose action discussed earlier.

Use the filter array action

Use the Filter array - Data Operation action to reduce the number of objects in an array to a subset that matches the criteria you provide.

Note

  • You can't use the filter array action to change the shape of objects in the array.
  • The text on which you filter is case-sensitive.

In this example, you use the filter array action on this array:

[ { "first": "Eugenia", "last": "Lopez" }, { "first": "Elizabeth", "last": "Moore" } ]

This example creates a new array that contains only objects in which first is set to Eugenia.

  1. Find, and then add, the Filter array action to your flow.

  2. Configure the filter array action as shown in the following screenshot.

    Screenshot of in the From section, the first line is set to Body. In the second line, first is set equal to Eugenia.

  3. Save, and then run your flow.

Use the create CSV table action

Use the Create CSV table - Data Operation action to change a JSON array input into a comma-separated value (CSV) table. You can keep the headers visible in the CSV output. In this example, you convert the following array into a CSV table:

[ { "first": "Eugenia", "last": "Lopez" }, { "first": "Elizabeth", "last": "Moore" } ]
  1. Find, add, and then configure the Create CSV table - Data Operation action to resemble the following image.

    Screenshot of Configuring the Create CSV table action. From is set to Body, and Columns is set to Automatic.

    The Body token in this image comes from a When a HTTP request is received action; however, you can get the input for the Create CSV table action from the output of any previous action in your flow, or you can enter it directly in the From box.

  2. Save, and then run your flow.

    When your flow runs, the Create CSV table action displays the output shown in the following screenshot.

    Screenshot of the output from the create CSV table action, showing "first,last" in the first row followed by "Eugenia,Lopez" and "Elizabeth,Moore."

Use the create HTML table action

Use the Create HTML table - Data Operation action to change a JSON array input into an HTML table. You can keep the headers visible in the HTML output.

To do this, follow the steps in the previous Use the create CSV table action section for creating a CSV table. Use the Create HTML table - Data Operation action instead of Create CSV table.

Tip

If you plan to send the HTML table via email, remember to select IsHtml in the email action.