cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ezrabutler
New Member

Simple Count in Power Automate and Sharepoint

I have a Sharepoint list that gets updated throughout the day by users on a PowerApp. In it, I have data coming in about residents from three facilities. Residents come and go all the time, so I have created one single line of text column for "Facility" names and another boolean column for "Current". 

 

I would like to run a report daily count on how many rows in the Sharepoint list of current residents in each facility, and put it in a separate list called "Daily Count".

 

I've figured out that in ODATA, `(Current eq true) and (Facility eq 'Facility 1')` should filter out all the non-current residents of a given facility. I just want to take that filtered data, count the number of items/rows, and put that into the new list. 


When I try the `length(outputs('Get_items')?['body'])` of the body of the list, it tells me that it's an Object and I can't take length() of an object. When I do `length(createArray(outputs('Get_items')?['body']))`, it returns a single result. 

 

I don't want to be running some sort of recursive loop to go through all 500+ residents one by one, because it seems wasteful and takes a long time.


What am I missing?

 

Thank you.

2 REPLIES 2
Abhilash_Swain
Super User
Super User

Hi @ezrabutler,
If I understood your requirement correctly,  you want to show something similar to the below screenshot.

Filter out data with "(Current eq true) " and then use the below logic to show.
SP List contains - Emp ID and Reporting Manager  and My power Apps shows count for each Manger 

Abhilash_Swain_0-1641193820200.png

Abhilash_Swain_1-1641193842500.png

 

For this, I use GroupBy in "Items" of the gallery. (Employee_office  is my source, "Manager"- Existing column in source, "total_Count"- is the group by column name.)

Please Note:- total_Count here represents a table stored under the column.

Abhilash_Swain_2-1641194025953.png

To display the count:-  Select Subtitle- Go to text and use the count formula to display no of rows in the group by.

Abhilash_Swain_3-1641194188537.png

 

 

 

Hope this will help you. 
Give a like or accept as a solution or share your concerns if this is not helping.

 

Eelman
Community Champion
Community Champion

@ezrabutler 

Try using this instead:

 

length(body('Get_items')?['value'])

 See here for more info

https://tahoeninjas.blog/2019/07/04/how-to-count-number-of-items-returned-by-sharepoint-getitems-act...

 

Helpful resources

Announcements
Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Super User 2 - 2022 Congratulations

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

September Events 2022

Check out all of these events

Attend in person or online, there are incredible conferences and events happening all throughout the month of September.

Government Carousel

New forum: GCC, GCCH, DoD - Federal App Makers (FAM)

In response to the unique and evolving requirements of the United States public sector, Microsoft has created Power Apps US Government.

Users online (5,447)