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

Announcements

News and Announcements icon
Community site session details

Community site session details

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

Count list items in Power Automate Flow

(2) ShareShare
ReportReport
Posted on by Microsoft Employee

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
    69,110 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
    Microsoft Employee 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Automate

#1
Haque Profile Picture

Haque 523

#2
Valantis Profile Picture

Valantis 318

#3
David_MA Profile Picture

David_MA 235 Super User 2026 Season 1

Last 30 days Overall leaderboard