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 Apps / How to count records w...
Power Apps
Answered

How to count records with multiple instance

(1) ShareShare
ReportReport
Posted on by Microsoft Employee

How to count records with multiple instance.

 

Sample Data:

Sun

Moon

Earth

Sun

Moon

Sun

 

Expected:

Sun = 3

Moon = 2

Earth = 1

Categories:
I have the same question (0)
  • BitLord69 Profile Picture
    914 on at

    Hi!

     

    I guess you mean that they are all individual records, but have the same values. You can do this with CountIf - you can see the documentation here: https://powerapps.microsoft.com/en-us/tutorials/function-table-counts/

     

    You can also get the distinct values, in your example you'd get only Sun, Moon and Earth. Read about Distinct here: https://powerapps.microsoft.com/en-us/tutorials/function-distinct/

     

    If you have a gallery you could use both formulas to get what you want. In the gallery's Item-property you have to use the Distinct function, and then in the template part you have to have a label with the Text-property set to the CountIf, something like this:

     

    CountIf(planetDB, HeavenlyBodyName = ThisItem.HeavenlyBodyName)

     

     

    Good luck!

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi,

     

    Thanks for the reply. I want to know the record with the most number of instance (same values).

     

    Thanks!

  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    You can use the GroupBy function to group your table by that variable, and then use the CountRows function to calculate the number of items on each group. If your data is in a collection called 'coll', and the name of the column that has the sample data is 'Name', then the expression below will give you a table that has a column for the name and another with the count of items of that name.

    AddColumns(
     GroupBy(coll, "Name", "ByName"),
     "Count",
     CountRows(ByName))
  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    This is not woring

  • patella Profile Picture
    12 on at

    This helped me to resolve a similar need, just wanted to correct the code referenced.  This is what should work (add ThisRecord. before ByName):

    AddColumns(
     GroupBy(coll, "Name", "ByName"),
     "Count",
     CountRows(ThisRecord.ByName))

     

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 March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 551

#2
WarrenBelz Profile Picture

WarrenBelz 430 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 298

Last 30 days Overall leaderboard