cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Super User III
Super User III

How to get a count of the number of rows returned?

Is there any direct way to retrieve the number of rows that are returned from a 'get rows' action?

 

This is what I've tried but it results in the error beneath. Ideally, I'd like to avoid looping around the results and incrementing a variable. Thanks!

 

Rowcount.PNG

 

 

InvalidTemplate. Unable to process template language expressions in action 'Compose' inputs at line '1' and column '1590': 'The template language expression 'length(outputs('GetRows').value)' cannot be evaluated because property 'value' doesn't exist, available properties are 'statusCode, headers, body'. Please see https://aka.ms/logicexpressions for usage details.'.

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Support
Community Support

Re: How to get a count of the number of rows returned?

Hi timl,

 

Hope my steps could be a reference for you:


1. Configure the flow looks like below, using the actions Get rows and Compose.
    About the Compose action, configure the length function with the dynamic content “value”.

3.PNG

2. Save the flow, you will get an error message. Replace the dynamic content “value” with the yellow highlighted part.
    The function in the Compose action would be "@length(body('Get_rows')?['value'])"

4.PNG

5.PNG

3. Update the flow, it will be saved successfully. Then click the button to run the flow, succeed.

6.PNG

 

Please try my steps to see if it will work for you. Please feel free reply if you need more help.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

13 REPLIES 13
Highlighted
Community Support
Community Support

Re: How to get a count of the number of rows returned?

Hi timl,

 

Hope my steps could be a reference for you:


1. Configure the flow looks like below, using the actions Get rows and Compose.
    About the Compose action, configure the length function with the dynamic content “value”.

3.PNG

2. Save the flow, you will get an error message. Replace the dynamic content “value” with the yellow highlighted part.
    The function in the Compose action would be "@length(body('Get_rows')?['value'])"

4.PNG

5.PNG

3. Update the flow, it will be saved successfully. Then click the button to run the flow, succeed.

6.PNG

 

Please try my steps to see if it will work for you. Please feel free reply if you need more help.

 

Best regards,
Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Highlighted
Super User III
Super User III

Re: How to get a count of the number of rows returned?

Thanks Mabel, that works perfectly!

Highlighted
Advocate II
Advocate II

Re: How to get a count of the number of rows returned?

Worked for me too - you need to remember to add double quotes at each end of the compose statement - when creating this in the expression it comes up as invalid so just ignore that.

Highlighted
Advocate IV
Advocate IV

Re: How to get a count of the number of rows returned?

Hi,,

I’ve tried with your exoression and returns full content of table not the numeric count
What could i be doing wrong ?
Just a remark I’m getting rows on sql on premises and Filtered
Highlighted
Advocate II
Advocate II

Re: How to get a count of the number of rows returned?

"@length(body('Get_rows')?['value'])" in the compose input. length will give the count of rows.

Highlighted
Advocate IV
Advocate IV

Re: How to get a count of the number of rows returned?

I'm getting this error:

 

The template validation failed: 'The action(s) 'Get_rows' referenced by 'inputs' in action 'Compose' are not defined in the template.'.

 

 

Screenshot 2018-11-13 at 21.36.15.png

Highlighted
Advocate II
Advocate II

Re: How to get a count of the number of rows returned?

The name of the ACTION is Get Rows Invoices (hover over the top of value under dynamic content and it should give you the name it is using). I suspect it is Get_rows_Invoices.  Replace Get_rows with this as in "@length(body('Get_rows_Invoices')?['value'])"  

Highlighted
Advocate IV
Advocate IV

Re: How to get a count of the number of rows returned?

😂

Yes you were correct.

Thank you very much.

I really must invite you one day to support us in our company. 😂

we use a lot Flow and O365 environment and i'm not a trained It guy

Highlighted
Advocate II
Advocate II

Re: How to get a count of the number of rows returned?

Very happy to help. Smiley Happy

Highlighted
Frequent Visitor

Re: How to get a count of the number of rows returned?

Thanks! Flow has made getting the length of an array as simple as resetting a lightbulb! https://www.youtube.com/watch?v=1BB6wj6RyKo

Highlighted
Helper V
Helper V

Re: How to get a count of the number of rows returned?

@v-yamao-msft 

By any chance can we get current item number/Row number during each iteration ..?

if yes how can we get during error handling i would like to get each line/row number where/when it throws error.

you reply would be really appreciated 

Highlighted
Advocate V
Advocate V

Re: How to get a count of the number of rows returned?

I do not think these instructions work anymore. Here is what I did in 2020, 3 years after this was posted, where I am sure things have changed a bit in the product.

  1. Created a Compose step after whatever got the records (SQL Power Query in my case)
  2. in the expression builder, typed Length(
  3. clicked on the body/value in the dynamic section
  4. EdHansberry_0-1598653036272.png

     

  5. Closed the paren.

that is it. It counts records returning an integer.  A fuller view of the flow:

EdHansberry_1-1598653533580.png

 

Highlighted
Super User III
Super User III

Re: How to get a count of the number of rows returned?

Thanks for posting this @EdHansberry. Things have changed so I'm sure this will be a great help to others.

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Upcoming Events

Experience what’s next for Power Automate

See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Users online (6,173)