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 / Issue with CountRows r...
Power Apps
Answered

Issue with CountRows result when trying to calculate number of selected items in gallery when using a container for each gallery item

(0) ShareShare
ReportReport
Posted on by 14

Hi All, I have come across a strange 'anomaly' when using the CountRows function as follows. It is easily reproducible.

Let's say we have a gallery, which shows all our records as normal from any data source. Now we need to select 'edit gallery' and add a checkbox control (so that it shows one for each row). Now we add a label outside the gallery, which will serve to display a 'count' value of how many records we have selected via the checkboxes which appear next to each row.

The formula is:    CountRows(Filter(Gallery1.AllItems, Checkbox1.Value)) & " selected" 

When we go to preview, it works fine as expected as can be seen by the first picture, where the label states '3 selected' as expected.
Screenshot 2024-05-08 173805.png
However, let's say we had separate identical gallery. We then do 'edit gallery' as before, but we add a Container in first, then a checkbox control as before, with the usual fields as previously. Again, we add a label control just like before to do our 'counting'.
It has a similar formula as before which is:  CountRows(Filter(Gallery1_1.AllItems, Checkbox2.Value)) & " selected".

However, as we now have a container, when we preview our app and select a checkbox, it does not count the number of selected rows. Instead, I get a total which is equivalent to the total number of records I have.  This is shown in my next screen-shot, where I've only selected one row, but  '96 selected' is shown in the label instead of '1 selected'.
 
Instead of '1 selected' we see '96 selected''Instead of '1 selected' we see '96 selected''
 
I guess it is because the checkbox is nested within the container, but has anyone experienced this before and more importantly, is there are way around this so that we can get a correct 'count' figure, other than not using a container?

Thank you all in advance!
Categories:
I have the same question (0)
  • IamnotBob Profile Picture
    51 on at

    Hi CobraKai.

    Which input checkbox are you using to get the count?

    The below both work for me. Both labels are outside of the gallery

    Input = Modern Checkbox

    CountRows(Filter(Gallery1.AllItems, Checkbox1.Checked)) & " selected" 

    Input = Classic Checkbox

    CountRows(Filter(Gallery1.AllItems, Checkbox1.Value)) & " selected" 

     

    Screenshot 2024-05-08 125451.png
  • CobraKai Profile Picture
    14 on at

    Hi @IamnotBob ,

    Thanks for replying. I can only see one type of checkbox control available to me. And it does not allow the .Checked property, only the .Value property.  My authoring version of PowerApps is:  3.24045.17

    The issue that I have reported only happens if you click on 'edit gallery' then add a container first of all. Then the other controls (including the checkbox and fields are inside it). Did you try it with a container? I have reproduced this issue in several PowerApps.

     

    Regards,

    CobraKai

  • Verified answer
    CobraKai Profile Picture
    14 on at

    Hi - Just letting everyone know, that I recreated this issue yesterday in a few apps, using totally different data sources just to be sure. They all exhibited the same behaviour with CountRows not showing the expected values when the checkbox was inside of a container. However, this morning, I was just about to remove the container to avoid this issue, but I thought I'd just try and select the checkboxes again (for some reason) - and the label is showing the correct result now!  I thought it must be a fluke, so I went to the other apps where I recreated this issue - and they too are all working now! So whoever at Microsoft fixed this, thank you so so much ! You've saved me a lot of work (and hassle!) Thank you! 😀

     

    Best Wishes,

    CobraKai

    (UK)

  • IamnotBob Profile Picture
    51 on at

    At one point we had to enable modern apps. Now you do not. In doing so this would show multiple controls. It is good they are cleaning it up and simplifying this. Good luck in your class. It is a good one.  

    Screenshot 2024-05-09 071627.png
  • CobraKai Profile Picture
    14 on at

    Ah ok, hence why there are two different types of checkboxes as you stated. That makes sense.


    Many thanks.

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 491

#2
WarrenBelz Profile Picture

WarrenBelz 407 Most Valuable Professional

#3
11manish Profile Picture

11manish 331

Last 30 days Overall leaderboard