Showing results for 
Search instead for 
Did you mean: 
New Member

Counting rows in a gallery after applying filters - CountIf and CountRows doesnt work unless the user scrolls the gallery:

Hi - I have a gallery that is filtered by and I want to then count how many of the rows have a status of Open and Closed - which are in a text field. The gallery will never be larger than 60 records; however, when I filter the gallery the CountIf and CountRows sometimes have the incorrect count, unless I scroll the vertical bar on the gallery. 


For example, I have tried CountIf(Gallery.AllItems, Status = "Closed") and CountRows(Filter(Gallery.AllItems, Status = "Closed")). 


Is there a way to refresh counts or the gallery or something - this seems like a very simple operation especially since the rows are always 60 or less. Thanks in advance for any help. 

Dual Super User III
Dual Super User III

By definition the Gallery is a paged view that only shows the first 100 records.  But if the gallery will never have more than 60 records then CountRows() should work fine.  Is Status a choice field?  if so you might need to use Status.Value = "Closed" or filter based on the value of the control in the gallery instead of the field.  Like this

CountRows(Filter(Gallery1.AllItems,Label3.Text = "Closed"))

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.
Helper III
Helper III

Please use the data source or the collection to count the rows instead of Gallery

Helper III
Helper III

I meant like this

ClearCollect(SPListCollection, Filter(SPList, Status = "Closed"));

Helpful resources

PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group


Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (91,078)