Skip to main content

Notifications

Community site session details

Community site session details

Session Id : LS/jYOjjctWRdYo4mfckV6
Power Automate - Building Flows
Answered

Count list items in Power Automate Flow

Like (1) ShareShare
ReportReport
Posted on 9 Feb 2022 14:36:43 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! 
  • Suggested answer
    Tanveer Ahmed S Profile Picture
    2 on 27 Aug 2024 at 10:51:51
    Count list items in Power Automate Flow
    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.

     
  • Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on 16 Feb 2022 at 17:13:05
    Re: Count list items in Power Automate Flow

    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.

  • AJ007 Profile Picture
    10 on 16 Feb 2022 at 03:24:49
    Re: Count list items in Power Automate Flow

    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?

  • Community Power Platform Member Profile Picture
    on 10 Feb 2022 at 09:10:30
    Re: Count list items in Power Automate Flow

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

  • Verified answer
    Paulie78 Profile Picture
    8,407 Super User 2025 Season 1 on 09 Feb 2022 at 20:31:07
    Re: Count list items in Power Automate Flow

    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 😘

     

  • Pstork1 Profile Picture
    66,093 Most Valuable Professional on 09 Feb 2022 at 14:50:03
    Re: Count list items in Power Automate Flow

    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.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,776 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,093 Most Valuable Professional

Leaderboard