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 / Help with summarising ...
Power Apps
Answered

Help with summarising a collection with counts

(0) ShareShare
ReportReport
Posted on by 26

Hello,

I have a collection which includes someone's name and a column with an item reference in there. It will include one row per item associated with someone's name, and there can be multiple records for the same person / item combination. The use-case is I'm attempting to log the user interactions (clicks) in parts of my app, and I want to use that to see the top x clicks for each user. I can do this easily outside of PowerApps. I think I can also do it in a gallery using labels and formulas. But what I really want is to do it within a collection so I can then make use of the calculated data within the app (e.g. show to the user the top x items they have clicked on based on the log).

 

A simplified example is this:

 

LogTable:

PersonItem
BobA
BobA
BobB
BobB
BobA
BobA
BobB
BobC
BobC
BobC
BobA
BobB
SarahA
SarahC
SarahD
SarahD
SarahD
SarahA
SarahD
SarahC
SarahE
SarahD
SarahA
SarahA

 

And I want to turn this into a summarised table like this:

PersonItemFrequency
BobA5
BobB4
BobC3
SarahA4
SarahC2
SarahD5
SarahE1

 

Where 'frequency' is the count of the rows in the log table with that person / item combination.

 

I have gone round and round in circles trying groupby and some forall loops, but can't quite crack this.  I can get the second table without the counts (i.e. the distinct person / item combinations from the log table) but can't work out how to then add the column of counts.

 

Any help would be really gratefully received. Many thanks

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Hi @desreed ,

    This should do it

    AddColumns(
     GroupBy(
     LogTable,
     "Person",
     "Item",
     "Data"
     ),
     "Frequency",
     CountRows(Data)
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

  • desreed Profile Picture
    26 on at

    Thank you @WarrenBelz . That's sorted it.

    I created a new collection with that code in. It left me with a 'data' column I didn't need, so added in a dropcolumns function to get rid of that, and it's sorted. Perfect! Thanks so much.

  • WarrenBelz Profile Picture
    156,748 Most Valuable Professional on at

    Thanks @desreed ,

    The data column (or whatever you want to call it - I just use Data) is a table containing the records from all the other fields that match the grouping.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 339 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 289

#3
Mohsin Ali Profile Picture

Mohsin Ali 228

Last 30 days Overall leaderboard