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 Duplicates in Array
Power Automate
Answered

Count Duplicates in Array

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

This should be simple but I just can't get around it. 

 

I have an array that lists a bunch of users' departments. Only the department names, so it looks like:

Human Resources
Finance
Operations
Human Resources

 etc.

Naturally there are duplicates, since some users in this list are from the same department. 

I want to count the duplicates. 

Basically I want a final list like:

12 users from: Human Resources

1 user from: Operations

2 Users from: Logistics

 

 

Categories:
I have the same question (0)
  • krootz Profile Picture
    458 on at

    @Anonymous 

    here's a sample flow and the output:

    flow1.pngflow2.pngflow3.pngoutput.png

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Thanks @krootz, I replicated your flow, but it seems to be timing out on the Each Dept action, with only 20 items in the array to loop through.  

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

    @Anonymous try this flow, very simple. Produces this output, but can easily be adjusted to be formed however you like:

    [
     {
     "Department": "HR",
     "Count": 12
     },
     {
     "Department": "Ops",
     "Count": 1
     },
     {
     "Department": "Logistics",
     "Count": 2
     }
    ]

    Fewer steps so less complicated https://ibb.co/54KZH4R (Easier to view on link):

    CountDuplicates.png

    Code for the append to results for you to copy and paste is:

    { 
     "Department": @{item()},
     "Count":@{length(body('Filter_array'))}
    }

     

    See how you get on.

     

    Please...

    If I answered your question Accept it as a solution ✔️ 

    If I helped you out, please give me some Kudos 👍

    Thanks 😙

  • krootz Profile Picture
    458 on at

    @Anonymous hmmm it only takes 10 secs for me to run it. 😅

  • krootz Profile Picture
    458 on at

    @Paulie78 I like this, it's simpler! 🙂

  • Paulie78 Profile Picture
    8,424 Moderator on at

    @krootz thank you. You have been making some really neat solutions. Have learned quite a bit from your posts.

  • grootgrootgroot Profile Picture
    2 on at

    When you are incrementing the variable under Apply to each, what is the value that you are using?
    The if(...)?

  • Swap2909 Profile Picture
    10 on at

    Hey 

     

    Thanks for your inputs. I tried using your solution here. It is counting but out it repeated. I have a list currently which has 24 entries - 14 of 1 type and 10 of others. I used the above flow to count these from a list - the output is coming as array of 24 items - 14 times for 1 type and 10 times for other - and does show the count. So it looks something like this

     

    Type 1 10

    Type 1 10

    Type 2 14

    Type 1 10

    Type 1 10

    Type 1 10

    Type 1 10

    Type 2 14

    Type 2 14

    Type 2 14

     

    and so on.

    How to do i correct to show like below

    Type 1 : 14

    Type 2 : 10 

    And maybe in future i will have a type 3 and so on 

  • Swap2909 Profile Picture
    10 on at

    Hey 

     

    Thanks for your inputs. I tried using your solution here. It is counting but out it repeated. I have a list currently which has 24 entries - 14 of 1 type and 10 of others. I used the above flow to count these from a list - the output is coming as array of 24 items - 14 times for 1 type and 10 times for other - and does show the count. So it looks something like this

     

    Type 1 10

    Type 1 10

    Type 2 14

    Type 1 10

    Type 1 10

    Type 1 10

    Type 1 10

    Type 2 14

    Type 2 14

    Type 2 14

     

    and so on.

    How to do i correct to show like below

    Type 1 : 14

    Type 2 : 10 

    And maybe in future i will have a type 3 and so on 

  • Chriddle Profile Picture
    8,686 Super User 2026 Season 1 on at

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!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Automate

#1
Vish WR Profile Picture

Vish WR 796

#2
Valantis Profile Picture

Valantis 568

#3
Haque Profile Picture

Haque 538

Last 30 days Overall leaderboard