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 / Gallery counter limited?
Power Apps
Answered

Gallery counter limited?

(1) ShareShare
ReportReport
Posted on by

I have a gallery that has about 178 items on it. i have a label with a counter with the formula Gallery1_1.AllItemsCount

 

The counter is always reading 100 unless i start scrolling down past 100 to start populating them. is there a way to always display the total number at the start if i do not scroll?

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    Hi @phillyd023,

     

    Data within gallery loads within batches of 100. Once you scroll down, the total count should change to 178 items.

     

    Should you want to view the exact row count, you will have to directly reference the datasource. In other words, this can be done by enclosing the code you wrote in the Items property of that gallery in a CountRows. This CountRows function will be written in the Label's Text property:

     

    //E.g. CountRows(TableName) or CountRows(Filter(...))
    CountRows(<Gallery Items code>)

     

    Alternatively, you could show a '+' icon as is explained in the following blog post. 

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

  • Verified answer
    CarlosFigueira Profile Picture
    Microsoft Employee on at

    @LaurensM answer is spot on - you need to reference the items from the gallery. You may not want to copy the formula so that you would have it in two places (and if you update one you may forget to update the other), so you should consider using a named formula which contain that expression, and reference that formula on both the gallery's Items property and in your label:

    App.Formulas: MyGalleryItems = <Existing gallery Items code>
    Gallery.Items: MyGalleryItems
    Label.Text: CountRows(MyGalleryItems)

    Hope this helps!

  • subsguts Profile Picture
    1,259 Moderator on at

    Thank you for the answer.  My Items property is extremely complex because it displays different items based on what the user has clicked on.  I guess I can wrap that in a CountRows, but WOW! that's a lot of code to wrap.  Switching to a collection at this point wouldn't be a good idea because this code is in production and that would require a full regression test.

     

    Just to be sure @RandyHayes posted the following several years ago, which I thought was a solution to my issue, but it doesn't appear to work anymore because the "Countrows(yourGalleryItems)" will not return the correct number.  I'm perplexed as to why this used to work as Randy is a Super Super User.

    Re: Gallery does not load data properly (need to s... - Power Platform Community (microsoft.com)

     

    Any ideas on this?

    Thank you!

  • subsguts Profile Picture
    1,259 Moderator on at

    @CarlosFigueira I'm not familiar with App.Formulas, or they were even possible.  Must of missed that class 🙂

    Please elaborate or provide a reference on how you set these up as this appears what I'll have to do if @RandyHayes solution is no longer viable.

     

    Thank you!

  • CarlosFigueira Profile Picture
    Microsoft Employee on at

    @subsguts you can learn more about named formulas at Power Fx: Introducing Named Formulas | Microsoft Power Apps. If you have an expression that you want to access in different places, you can define it there and you can reference that "name" from anywhere in your app. Currently this feature is in preview, so new apps have it enabled by default, but if your app is older you may need to go to the settings and enable it explicitly (it should be declared GA - general availability - very soon).

    Once you enabled that feature, you can move the complex expression from the Items property of your gallery to a named formula (for example, called "MyGalleryItems" as I had in the example in my previous post); at that point, you can reference 'MyGalleryItems' from your gallery (i.e., replacing the complex formula with that name), and also reference that from the label with the CountRows expression.

    Hope this helps!

  • subsguts Profile Picture
    1,259 Moderator on at

    Ok, so I turned on the Named Formulas and add the very complex contents of my Items property below.  However, the when I try and put "galRequestsItems" into the Items property of the gallery it doesn't recognize it and gives and error "Expected Table Value".  What am I missing?  Thank you

     

    galRequestsItems =
    If(
    isAdmin,// This section is the same as the User section below except it doesn't include the GUID compare in the Filter since Admins can see all requests
    //Adding in section so that this is restricted based on the AssignedTo field for the the Admin unless they have clicked
    //on the button to show all requests. Default should be their requests.
    If (
    varShowSubmittedRequests,
    If(
    varTab = "InProgress" || varStatus = "In Progress" || varStatus = "Returned",
    //Get all the records that have an In Progress or Returned status, which are both valid for the InProgress Tab
    (SortByColumns(
    Filter(
    CDMRequests,
    Archived = 0 And (Status = "In Progress" Or Status = "Returned")
    ),
    "Created",
    SortOrder.Descending
    )),
    If(
    //Get all the records that have an for the other statuses (except Archive) that have 1 to 1 association with the Tabs
    varStatus = "Submitted" || varStatus = "Actively Reviewing" || varStatus = "Pending Pricing Review" || varStatus = "Sent for Approval" || varStatus = "Completed",
    (SortByColumns(
    Filter(
    CDMRequests,
    Archived = 0 And (Status = varStatus)
    ),
    "Created",
    SortOrder.Descending
    )),
    If (
    //Get all the records that have been put on hold and should appear on the Hold Tab
    varTab = "Hold",
    (SortByColumns(
    Filter(
    CDMRequests,
    Archived = 1
    ),
    "Created",
    SortOrder.Descending
    ))
    )
    )
    ),
    If(
    varTab = "InProgress" || varStatus = "In Progress" || varStatus = "Returned",
    //Get all the records that have an In Progress or Returned status, which are both valid for the InProgress Tab
    (SortByColumns(
    Filter(
    CDMRequests,
    Archived = 0 And (Status = "In Progress" Or Status = "Returned") And UserGUID = varUserGUID
    ),
    "Created",
    SortOrder.Descending
    )),
    If(
    //Get all the records that have an for the other statuses (except Archive) that have 1 to 1 association with the Tabs
    varStatus = "Submitted" || varStatus = "Actively Reviewing" || varStatus = "Pending Pricing Review" || varStatus = "Sent for Approval" || varStatus = "Completed",
    (SortByColumns(
    Filter(
    CDMRequests,
    Archived = 0 And (Status = varStatus) And AssignedToGUID = varUserGUID
    ),
    "Created",
    SortOrder.Descending
    )),
    If (
    //Get all the records that have been put on hold and should appear on the Hold Tab
    varTab = "Hold",
    (SortByColumns(
    Filter(
    CDMRequests,
    Archived = 1 And AssignedToGUID = varUserGUID
    ),
    "Created",
    SortOrder.Descending
    ))
    )
    )
    )
    ),
    //This is the section just for users and will show all their requests because of the GUID comparison, each user has their own unique
    If(
    //Get all the records that have been put on hold by the user and should appear on the Hold Tab
    varTab = "Hold",
    (SortByColumns(
    Filter(
    CDMRequests,
    UserGUID = varUserGUID And Archived = 1 And (Status = "In Progress" || Status = "Returned")
    ),
    "Created",
    SortOrder.Descending
    )),
    //The user will only see InProgress or Returned Requests unless they change the filter to show Submitted requests. In either case, Hold will not be shown
    //except under the Hold tab
    If(
    varShowSubmittedRequests,
    (SortByColumns(
    Filter(
    CDMRequests,
    UserGUID = varUserGUID And Archived = 0
    ),
    "Created",
    SortOrder.Descending
    )),
    (SortByColumns(
    Filter(
    CDMRequests,
    UserGUID = varUserGUID And Archived = 0 And (Status = "In Progress" || Status = "Returned")
    ),
    "Created",
    SortOrder.Descending
    ))
    )
    )
    );

  • subsguts Profile Picture
    1,259 Moderator on at

    @CarlosFigueira Another problem, even if I leave my Items as is and use this as a formula to get the number of items in the Gallery, which appears to work, I still can't select that item.

     

    So it my case the Gallery has 228 items.  By saying CountRows(galRequestsItems) I get 228.  

     

    However, when I try to do Select(galRequests, 228) it cannot find it as it says row or column is out side the bounds of the range (paraphrasing).  However, if I Do a Select(galRequests, 100), then a Select(galRequests, 150), etc. I can get to 228, but it will not allow me to jump to the end of the items.

    I need to have the whole list loaded becuase there is another screen where you can search for a request and then come back to the main screen where this gallery is and it will select the request so you can see the details.  This functionality only works, currently, if the item you find in the Search Screen is one of the first 100 items in the list.  Therefore, that is why I need to force the entire list to load and it appeared the way to do this was to force the list to load by selecting the last items using what has been discussed above.  

    Any help is GREATLY appreciated.

     

    @LaurensM please add your comments as well as you both seem to understand this a great depth.

  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @subsguts,

     

    I took a look at the Timer control workaround and I got it working (kind of) when creating a loop depending on the start and end count of my gallery items. Only running the Timer control once will simply fetch the next 100 batch. That said, the Timer loop in my case was quite inconsistent with large lists.

     

    Should you always want access to all records, generally speaking, you will have to load them into a collection and recollect when changing filters. The With() function would also allow you to store them in memory without the need for a collection by using the following structure:

     

    //Items property of your gallery
    With(
     {
     wFilter: <Your current items code here> 
     },
     wFilter
    )

     

    The code above will load the wFilter input into memory and you should be able to access all records within that Filter() output. (Solving the Select() 'outside the bounds of ...' issue & AllItemsCount only showing 100 until scrolling down)

     

    An option you could explore that does not involve loading data into memory, is adding a selected ID filter that is automatically populated when selecting a record. When navigating back after making changes to that record / searching for a request, the filter will still be in place - only displaying that particular record. The user can then remove the filter (e.g. via a cancel icon) to display all records.

     

    As for the issue with Named Forumulas, I unfortunately have not been able to recreate this on my end yet. Does the issue remain when only using a small subsection of your nested If() statements? However, using the With() code you may not need to use a named formula since you will only reference this code in the With function.

    Additionally, I am quite positive that we can avoid a lot of the If() statements by using Or & And statements within your conditions. My availability is currently quite limited so I will need to investigate code improvements in more detail later this week / weekend. Below a very simplified example:

     

     

    If(
     varTab = "Hold",
     Filter(..., Archived = 1),
     Filter(..., Archived = 0)
    )
    
    //Shorter code:
    Filter(..., (varTab = "Hold" && Archived = 1) || Archived = 0 &&...)

     

    Should you be interested in improving the nested If() code, I would recommend creating a new topic for this on the forum with your code. Due to the longer code size, I would recommend using the code block component (see my code above) and formatting your code to improve readability. 😊

    I hope this helps!

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

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 392 Most Valuable Professional

#2
11manish Profile Picture

11manish 181 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 112 Super User 2026 Season 2

Last 30 days Overall leaderboard