web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / Count list items in Po...
Power Automate
Unanswered

Count list items in Power Automate Flow

(2) ShareShare
ReportReport
Posted on by

Dear community,

 

I have created a flow which:

  • get elements from a SharePoint list 
    • filter the elements based on ODATA
  • -select the results 

The results are in the following format: 

[
  {
    "ID""A"
  },
  {
    "ID""A"
  },
  {
    "ID""B"
  },
  {
    "ID": "A"
  },
]
 
Without "Apply to each" I would like to find a quicker method to count unique elements and the results, sort descendant and to show the results in the following form:
A - 3
B - 1 
 
Does anybody have any idea if this is doable in PowerAutomate? Tried different methods w/o success.

Thanks! 
Categories:
I have the same question (1)
  • Pstork1 Profile Picture
    68,697 Most Valuable Professional on at

    There is no simple way to do this, but it can be done without using an Apply to Each.  

    1) Do a Filter Array action for each value you want to count.

    2) Use Length() on the resulting array. That will give you a count for that value.

    repeat process for each distinct value.

  • Verified answer
    Paulie78 Profile Picture
    8,422 Moderator on at

    Hi @Anonymous,

     

    I've done a video for you that demonstrates a high performance way of counting the distinct items in an array, without having to use a filter action or any apply to each loops. Check it out:

     

    How to count the number of Distinct Items in an Array in Power Automate

     

    Hope this helps.

     

    Blog: tachytelic.net

    YouTube: https://www.youtube.com/c/PaulieM/videos

    If I answered your question, please accept it as a solution 😘

     

  • Community Power Platform Member Profile Picture
    on at

    @Paulie78  - SUPER THANKS! It works great, and saves a lot of time. 

  • AJ007 Profile Picture
    10 on at

    Hi Paulie,

     

    Brilliant thanks for this and good timing. I do need to do a mass delete of records in the Teams Table. Unfortunately our IT have locked access to the HTTP action.

     

    So I was going to leverage an earlier solution of your which uses Threads. I was going to run the Threads concurrently and the first thread would process rows 1 - 5000, the second thread 5001 - 1000 as so one. Within each thread there would be the 'apply to each' to 'delete row', which again would run concurrently maxing out a 50.

     

    My issue is that I do not know how to select rows  1 - 5000, 5001 - 1000 etc of a Teams Table. With a SharePoint list I can use the ID column. In the Teams Table I have created an AutoNumber column but this is saved as a text. I'm guessing a solution might involve Fetch XML Query in the List Rows action?

     

    Appreciate any suggestion?

  • Paulie78 Profile Picture
    8,422 Moderator on at

    HI @AJ007 - I don't think I would bother with the threaded method for your use case. Why not just use one apply to each with the concurrency set to the maximum - it would be a much more simplistic flow.

  • Suggested answer
    Tanveer Ahmed S Profile Picture
    2 on at
    To count the number of items in a SharePoint list using Power Automate Flow, just follow the below TWO steps:
    1. Add a SharePoint HTTP Request Action:
      • Configure the Action:
        • Site Address: Select the appropriate SharePoint site.
        • API Endpoint: Use
          /_api/web/lists/getbytitle('<List Title>')/ItemCount
          .
    2. Add a Compose Action:
      • Configure the Compose Action:
        • In the Inputs field, use the following expression to extract the item count:
          body('Send_an_HTTP_request_to_SharePoint')?['d/ItemCount']


          You can either you use a variable or compose action to use this value anywhere in the flow.

    This approach efficiently retrieves the item count, even if the list exceeds the threshold limit, and works for both lists and libraries.

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 538 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 405 Moderator

#3
abm abm Profile Picture

abm abm 252 Most Valuable Professional

Last 30 days Overall leaderboard