cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
xecho
Helper I
Helper I

Get number of items in SP list fast

Hi,

 

I have a SP list with close to 5000 items. I just want to have a quick count of how many items there are actually in this list.

 

I can get the number of items with Flow through GetItems, but that is really slow, it is taking around 2 minutes.

 

Is there any other solution which would be much faster?

 

Thanks,

Bart

1 ACCEPTED SOLUTION

Accepted Solutions
Expiscornovus
Dual Super User
Dual Super User

Hi @xecho,

 

The list should have a property called ItemCount. You can retrieve that via REST API. Just tested it, should take less than 1 second 😁

 

1. Setup of the flow

 

_api/web/lists/getbytitle('@{variables('ListName')}')/ItemCount

itemcount.png

 

2. Test run with a list with 14000+ items

 

zeroseconds_sufficient.png

View solution in original post

7 REPLIES 7
Expiscornovus
Dual Super User
Dual Super User

Hi @xecho,

 

The list should have a property called ItemCount. You can retrieve that via REST API. Just tested it, should take less than 1 second 😁

 

1. Setup of the flow

 

_api/web/lists/getbytitle('@{variables('ListName')}')/ItemCount

itemcount.png

 

2. Test run with a list with 14000+ items

 

zeroseconds_sufficient.png

xecho
Helper I
Helper I

That worked great.

 

thanks!

and how would you filter this list before counting?

xecho
Helper I
Helper I

Not sure what you mean, it is an item count, a number, so nothing to sort :-).

 

The list in Powerapps can be sorted in Powerapps by Sort(listname, variable_for_sorting, Ascending/Descending);

 

for example I want to get all the items in that sharepoint list that have the assign column as true (using a flow)

Expiscornovus
Dual Super User
Dual Super User

Hi @Robert94,

 

That ItemCount is just a property in the list settings which retrieves and tracks all items in the list. As far as I am aware you cannot combine it with a $filter query parameter and the list items method.

 

But I might be wrong, let me have a quick look in my development tenant 😁

Expiscornovus
Dual Super User
Dual Super User

Hi @Robert94,

 

It still looks like combining those two is not possible.

 

However, in your setup you might be able to just first filter and count the number of items afterwards with a length function. For the OP that was not an option, but that might be an option for you 😁

 

Below is an example.

 

This is the URI I used, which checks if Assigns is equal to true (1) with a $filter query parameter

_api/web/lists/getbytitle('@{variables('ListName')}')/Items?$select=Title,Id,Assign&$filter=Assign eq 1

 

This is the expression to count the number of items from the result.

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

 

filter_countafterwards.png

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.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (1,549)