0

I am trying to count the number of occurrences of each item in a PowerApps Collection.

SharePoint List Name: Product

Desired Result

Fruit    Number of Occurrences
Apple            1
Orange           1
Apple            2
Banana           1
Orange           2
Apple            3
Banana           2
Banana           3
Watermelon       1
Apple            4
Bas H
  • 2,114
  • 10
  • 14
  • 23

1 Answers1

0

Use GroupBy to do the grouping by Fruit and AddColumnsto add a new column to store the group count.

Assuming you are planning to display the above in a Vertical Gallery, you can use this formula in the Items property:

AddColumns(GroupBy(Product, "Fruit", "Grouped"), "FruitCount", CountRows(Grouped))

Please see a screenshot below. I am using Departments instead of Fruits, but the concept is the same.

enter image description here

thebernardlim
  • 755
  • 2
  • 10
  • 23
  • Where do I put this? Can I add this to the clearcollect code? Please point me in the right direction – Kendall Outlaw May 04 '23 at 06:06
  • I updated my answer. Please have a look to see if it is clearer now. – thebernardlim May 04 '23 at 07:38
  • I don't think you understand what I am trying to accomplish. I do not want to group the data in the collection. In my example below I want to show every record in the collection and display the number of occurrences of each item in the collection. Fruit Number of Occurrences Apple 1 Orange 1 Apple 2 Banana 1 Orange 2 Apple 3 Banana 2 Banana 3 Watermelon 1 Apple 4 – Kendall Outlaw May 04 '23 at 11:25