Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

Power Automate Count Rows in Dataverse: List Rows and length()

Your flow pulled rows from a Dataverse table, and now you need to know how many came back. Wrap the List rows output in length() inside a Compose action, and you get the count as a number.

In this tutorial, we’ll walk through each Power Automate count rows case you’ll hit in a real flow: all rows, filtered rows, zero rows, a FetchXML count, and the Row count and 5,000-row limits.

Here’s the expression, with List_rows as your action’s name:

length(outputs('List_rows')?['body/value'])

It returns an integer. In our Service Requests table, it returned 6.

How to Count Rows From List Rows in Power Automate

We tested this on a Service Request table in a developer environment. If Dataverse is new to you, read what Microsoft Dataverse is first. The build takes four actions:

  1. Open make.powerautomate.com, pick the environment that holds your table, and select Create > Instant cloud flow > Manually trigger a flow.
  2. Select Add an action, search Dataverse, select See more, then pick List rows.
  3. Choose the Table name and, optionally, the Select columns.
  4. Add a Compose action with the length() expression, then Save and Test > Manually > Run flow.

Here’s the Microsoft Dataverse action list. The actions show the premium diamond icon:

Add an action pane with the Microsoft Dataverse actions listed and List rows highlighted

We picked the Service Requests table and limited the columns. Fewer columns make a smaller response, and the count doesn’t change:

List rows parameters with Table name Service Requests and Select columns filled in

The cr85a_ prefix is our publisher prefix; your columns will show your own. The Compose action, named Count all rows, holds this expression in Code view:

"inputs": "@length(outputs('List_rows')?['body/value'])"
Count all rows Compose action in Code view showing the length expression on body/value

After the run, open Count all rows. The output is 6, one for each row in the table:

Flow run with the Count all rows Compose output showing 6

How Do You Count Only Filtered Rows?

Filter in List rows, then count. Dataverse does the filtering, so the flow only receives matching rows. Our OData filter query examples cover the operators. We counted Open requests with this Filter rows value:

cr85a_status eq 770700000
List open requests action with Filter rows set to cr85a_status eq 770700000

The same length() expression on List_open_requests returned 3, because three of the six requests are Open:

Flow run with the Count open requests Compose output showing 3

Choice columns need the number, not the label. Our test with cr85a_status eq 'Open' failed with BadRequest: “A binary operator with incompatible types was detected.” To find the numbers, see how to get a Dataverse choice column value.

What Happens When List Rows Returns No Rows?

Nothing breaks. We filtered on a subject that didn’t exist yet:

cr85a_subject eq 'Projector Setup'

List rows succeeded, body/value was an empty array, and length() returned 0. No error, no null.

So you can branch on the count with a Condition: is length(…) greater than 0. Our post on Power Automate if length conditions shows that pattern, and checking if an array is empty covers empty().

Count Rows With a FetchXML Aggregate Query

length() downloads every row before counting. A FetchXML aggregate asks Dataverse for the number only. We put this in the List rows Fetch Xml Query field:

<fetch aggregate="true">
  <entity name="cr85a_servicerequest">
    <attribute name="cr85a_servicerequestid" alias="total" aggregate="count" />
  </entity>
</fetch>
List rows Fetch Xml Query field with an aggregate count FetchXML query

The result is one row with a total column. Read it with this expression:

first(outputs('Count_with_FetchXML')?['body/value'])?['total']
Flow run with the FetchXML total Compose output showing 6

It returned 6, matching length(). One warning: Microsoft Learn currently says aggregation queries aren’t supported in List rows FetchXML. It worked in our 10/20/2026 test, but treat it as undocumented.

Aggregate queries also stop at 50,000 records with an AggregateQueryRecordLimit exceeded error. Add a filter, such as a date range, and run it in parts.

Row Count, $top and the 5,000-Row Limit

Row count caps how many rows List rows returns, like $top. We set Row count to 3 and Sort By to cr85a_requestnumber asc:

List top 3 action with Sort By cr85a_requestnumber asc and Row count 3

length() returned 3. So never count rows from an action that has Row count set; you’ll get the cap, not the total.

Without Row count, List rows returns up to 5,000 rows per page. A table with 8,000 rows still counts as 5,000 unless you page.

To page, open List rows, select Settings > Networking, turn on Pagination, and set a Threshold. The maximum is 100,000, rounded up in 5,000-row steps.

Pagination doesn’t apply to FetchXML queries. For bigger tables, loop on @odata.nextLink. Our REST API pagination in Power Automate post shows a similar loop.

How to Count Rows in an Array

The same length() works on any array, not only List rows. To count matching items after you already have the rows, use Filter array, then:

length(body('Filter_array'))

Our Power Automate filter array examples show the conditions. Still, Filter rows is faster for Dataverse, because only matching rows leave the server.

If you see “The template language function ‘length’ expects its parameter to be an array or a string”, you passed an object. Point length() at body/value, and see this length error fix.

For SharePoint lists, the steps differ a bit; see counting items in a SharePoint list with Power Automate. More flows live in our Power Automate tutorials.

Building more Dataverse flows? These pick up where counting leaves off:

Frequently Asked Questions

How do I count rows from List rows in Power Automate?

Add a Compose action after List rows with length(outputs(‘List_rows’)?[‘body/value’]). Replace List_rows with your action’s name. The output is the number of rows the action returned.

Why does my Dataverse row count stop at 5,000?

List rows returns up to 5,000 rows per page by default. Turn on Pagination in Settings > Networking and set a Threshold of up to 100,000. Microsoft explains it in Use lists of rows in flows.

What does length() return when no rows match?

0. In our test, a filter with no matches returned an empty array, and length() returned 0 without an error.

How do I count only some rows in a Dataverse table?

Put an OData filter in Filter rows, such as cr85a_status eq 770700000, then use length() on that action’s body/value. Choice columns need the number value, not the label.

Can I count rows without downloading them?

Yes, with a FetchXML aggregate count in the Fetch Xml Query field. It worked in our test, but Microsoft Learn doesn’t document aggregates as supported in List rows, and aggregates stop at 50,000 records.