How to Count Rows From Dataverse Table Using Power Automate

To count rows from a Dataverse table using Power Automate, we can use the Power Automate Length() function.

The Length function allows you to quickly count the number of rows in a Dataverse table, making it easy to get the total number of records.

In this tutorial, I will show you how to use the Length function to count rows from a Dataverse table in Power Automate and demonstrate how to count filtered rows in a Dataverse table using Power Automate.

Count Rows in Dataverse Table

Below is a Dataverse table, Employee Records, that contains the Employee ID, Name, Department, Position, and Hire Date.

count rows in dataverse table in Power Automate

I have nine rows in the Employee Records; we will create a flow and verify the row count.

  1. Go to Power Automate and create a new instant cloud flow by manually triggering a flow trigger.
  2. Then add a List rows action present under the Microsoft Dataverse and provide the below parameters:
    • Table name: Select the Employee Records from the dropdown.
Power Automate Count Rows in Dataverse Table

This action gets our Employee Records table rows in an array format.

  1. Then add compose action and provide the below expression to count the rows:
length(outputs('List_rows')?['body/value'])
How To Get Dataverse List Rows Count Using Power Automate
  1. Then, save the flow and run it manually. Once the flow runs successfully, click the compose action, and then you can see the count of rows in the output section.
Count Rows From Dataverse Table Using Power Automate

This way, we can count the rows from the Dataverse table using Power Automate.

Count Filtered Rows in Dataverse Table

Now, let’s say you want to count only specific rows based on a condition (for example, count only employees from the IT department).

We can still use the length function, but first, we need to apply a filter to the action of the list rows.

Follow the steps below:

  1. Go to the Power Automate site and create a new Instant cloud flow with the Manually trigger a flow trigger.
  2. Add a List rows action from the Microsoft Dataverse connector. Provide the following parameters:
    • Table name: Select Employee Records from the dropdown.
    • Filter rows: Enter a filter expression. This should be a valid OData filter that matches your condition.
cr0e5_department eq 'IT'
How to Count Dataverse List Rows using Power Automate
  1. Add a Compose action. In the Inputs field, use the following expression to count the filtered rows:
length(outputs('List_rows')?['body/value'])
How To Get Dataverse List Rows Count Using Power Automate
  1. Save the flow. Run it manually.
  2. After the flow runs successfully, click on the Compose action. In the output section, you will see the count of only the filtered rows (for example, how many employees are from the IT department).
Power Automate Count Filtered Rows in Dataverse Table

This way, by using the Filter rows option in the List rows action along with the Length function, you can easily count only the filtered rows from a Dataverse table using Power Automate.

Other Dataverse articles you may also like:

Power Apps functions free pdf

30 Power Apps Functions

This free guide walks you through the 30 most-used Power Apps functions with real business examples, exact syntax, and results you can see.

Download User registration canvas app

DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App