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 Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

365 EduCon 768x460.png

Microsoft 365 EduCon

Join us for two optional days of workshops and a 3-day conference, you can choose from over 130 sessions in multiple tracks and 25 workshops.

Users online (4,995)