I'm trying to create a "Totals" page after a gallery in my app, but I need more than your regular CountRows formula - I need to be able to count the number of uniqe rows. My data is "Activities" and each row constitutes an activity run by a school. However, I need to total these numbers based on the number of schools involved. For example, I might have 10 activities run (total activities) but six schools involved because two schools ran only one activity while the others ran two activities each. I've been unsuccessful in creating a formula for this!
Any help much appreciated 🙂
Solved! Go to Solution.
Thanks for the reply. My data is very simple and I hope that I can explain it as much as possible. I've attached a screenshot of my data.
As you can see from the data below, i have 21 schools who have run activities. However, only 15 unqiue regions were involved, and only 11 unique activities were run.
I need to be able to count the number of schools involved (which is not as simple as using CountRows against my Gallery because there are often schools who run multiple activities. I also need to count the unique regions (i.e., 15 in the example above) and the number of unique activities.
I also need to list these unique items (i.e., schools, activities, and regions) too. I've attached a second screenshot which is a draft of my app - in circle 1, I need a list of those schools, regions, and activities, and in circle 2 I simply need the sum of what I've described above
Thanks again for your help!
Have you tried using the Distinct function?
For the list you can add this in the Items field of 3 diiferent galleries -
Distinct(DetailsGallery,School) Distinct(DetailsGallery,Region) Distinct(DetailsGallery,Activity)
And to count the rows -
CountRows(DetailsGallery,School) and similarly others.
Hope this helps!
Thanks for your reply! I tried the Distinct formula, but it doesn't work as it needs a table and comes up with invalid function.
CountRows also doesn't work, as it counts all of the rows in the source (i.e., DetailsGallery). I do have this formula for my # Activities though, as every row in my spreadsheet counts as an individual activity.
I was looking at your table for about an 1/2 an hour and I just couldn't understood it. I really apologies for it. What do you mean by unique regions and unique activities? How can I find those unique regions and unique activities in your table what you have posted? If you have another table what specify which regions and which activities are unique then please post it so I can figure out how did you get 15 unique regions and 11 unique activities. And also from your table is not quite clear what school run multiple activities
Happy to help.
Actually vivekb has already answered both of your questions.
Create 3 Galleries (GalleryA,GalleryB,GalleryC)
GalleryA.Items = Distinct(DetailsGallery,School)
GalleryB.Items = Distinct(DetailsGallery,Region)
GalleryC.Items = Distinct(DetailsGallery,Activity)
Also you can use the source of DetailsGallery in the Distinct function instead of DetailsGallery.
Let me know if you need further help.
Ahh, I made an error while pasting the formula. Thanks for the correction @Mike8
@ek21 : I think you want to display all the unique items in one text box like - School A, School B, School C, etc.
To achieve this, you probably want to display the list in a label. So, set the text property of the label to
Concat function joins all text values of a given column in a table.
You can do the same for Region and Activity
Concat(Distinct(DetailsGallery,Region),Region,", ") Concat(Distinct(DetailsGallery,Activity),Activity,", ")
Hope this helps!
Keep up to date with current events and community announcements in the Power Apps community.
A great place where you can stay up to date with community calls and interact with the speakers.
Check out the latest Community Blog from the community!