cancel
Showing results for 
Search instead for 
Did you mean: 
Reply

Gallery counter limited?

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?

2 ACCEPTED SOLUTIONS

Accepted Solutions

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!

View solution in original post

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

View solution in original post

9 REPLIES 9

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!

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

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!

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

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

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
))
)
)
);

@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.

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!

Very useful insights.  I will definitely be able to use these to help get to a solution.  I'm hopeful, I won't have to use the filter as with the way the App works it will be hard to intuitively add another icon that will let them unfilter (this is hard to explain why without going into lengthy detail about the app).

 

I will be looking into using a timer and if that works I will definitely post something here and/or in a new thread if I can get it to work efficiently and accurately.

 

Thank you so much!

Helpful resources

Announcements

Community will be READ ONLY July 16th, 5p PDT -July 22nd

Dear Community Members,   We'd like to let you know of an upcoming change to the community platform: starting July 16th, the platform will transition to a READ ONLY mode until July 22nd.   During this period, members will not be able to Kudo, Comment, or Reply to any posts.   On July 22nd, please be on the lookout for a message sent to the email address registered on your community profile. This email is crucial as it will contain your unique code and link to register for the new platform encompassing all of the communities.   What to Expect in the New Community: A more unified experience where all products, including Power Apps, Power Automate, Copilot Studio, and Power Pages, will be accessible from one community.Community Blogs that you can syndicate and link to for automatic updates. We appreciate your understanding and cooperation during this transition. Stay tuned for the exciting new features and a seamless community experience ahead!

Summer of Solutions | Week 4 Results | Winners will be posted on July 24th

We are excited to announce the Summer of Solutions Challenge!   This challenge is kicking off on Monday, June 17th and will run for (4) weeks.  The challenge is open to all Power Platform (Power Apps, Power Automate, Copilot Studio & Power Pages) community members. We invite you to participate in a quest to provide solutions in the Forums to as many questions as you can. Answers can be provided in all the communities.    Entry Period: This Challenge will consist of four weekly Entry Periods as follows (each an “Entry Period”)   - 12:00 a.m. PT on June 17, 2024 – 11:59 p.m. PT on June 23, 2024 - 12:00 a.m. PT on June 24, 2024 – 11:59 p.m. PT on June 30, 2024 - 12:00 a.m. PT on July 1, 2024 – 11:59 p.m. PT on July 7, 2024 - 12:00 a.m. PT on July 8, 2024 – 11:59 p.m. PT on July 14, 2024   Entries will be eligible for the Entry Period in which they are received and will not carryover to subsequent weekly entry periods.  You must enter into each weekly Entry Period separately.   How to Enter: We invite you to participate in a quest to provide "Accepted Solutions" to as many questions as you can. Answers can be provided in all the communities. Users must provide a solution which can be an “Accepted Solution” in the Forums in all of the communities and there are no limits to the number of “Accepted Solutions” that a member can provide for entries in this challenge, but each entry must be substantially unique and different.    Winner Selection and Prizes: At the end of each week, we will list the top ten (10) Community users which will consist of: 5 Community Members & 5 Super Users and they will advance to the final drawing. We will post each week in the News & Announcements the top 10 Solution providers.  At the end of the challenge, we will add all of the top 10 weekly names and enter them into a random drawing.  Then we will randomly select ten (10) winners (5 Community Members & 5 Super Users) from among all eligible entrants received across all weekly Entry Periods to receive the prize listed below. If a winner declines, we will draw again at random for the next winner.  A user will only be able to win once overall. If they are drawn multiple times, another user will be drawn at random.  Individuals will be contacted before the announcement with the opportunity to claim or deny the prize.  Once all of the winners have been notified, we will post in the News & Announcements of each community with the list of winners.   Each winner will receive one (1) Pass to the Power Platform Conference in Las Vegas, Sep. 18-20, 2024 ($1800 value). NOTE: Prize is for conference attendance only and any other costs such as airfare, lodging, transportation, and food are the sole responsibility of the winner. Tickets are not transferable to any other party or to next year’s event.   ** PLEASE SEE THE ATTACHED RULES for this CHALLENGE**   Week 1 Results: Congratulations to the Week 1 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersNumber of SolutionsSuper UsersNumber of Solutions @anandm08  23 @WarrenBelz  31 @DBO_DV  10 @Amik  19 AmínAA 6 @mmbr1606  12 @rzuber  4 @happyume  7 @Giraldoj  3@ANB 6 (tie)   @SpongYe  6 (tie)     Week 2 Results: Congratulations to the Week 2 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge. Community MembersSolutionsSuper UsersSolutions @anandm08  10@WarrenBelz 25 @DBO_DV  6@mmbr1606 14 @AmínAA 4 @Amik  12 @royg  3 @ANB  10 @AllanDeCastro  2 @SunilPashikanti  5 @Michaelfp  2 @FLMike  5 @eduardo_izzo  2   Meekou 2   @rzuber  2   @Velegandla  2     @PowerPlatform-P  2   @Micaiah  2     Week 3 Results: Congratulations to the Week 3 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 3:Community MembersSolutionsSuper UsersSolutionsPower Apps anandm0861WarrenBelz86DBO_DV25Amik66Michaelfp13mmbr160647Giraldoj13FLMike31AmínAA13SpongYe27     Week 4 Results: Congratulations to the Week 4 qualifiers, you are being entered in the random drawing that will take place at the end of the challenge.   Week 4:Community MembersSolutionsSuper UsersSolutionsPower Apps DBO-DV21WarranBelz26Giraldoj7mmbr160618Muzammmil_0695067Amik14samfawzi_acml6FLMike12tzuber6ANB8   SunilPashikanti8

Check Out | 2024 Release Wave 2 Plans for Microsoft Dynamics 365 and Microsoft Power Platform

On July 16, 2024, we published the 2024 release wave 2 plans for Microsoft Dynamics 365 and Microsoft Power Platform. These plans are a compilation of the new capabilities planned to be released between October 2024 to March 2025. This release introduces a wealth of new features designed to enhance customer understanding and improve overall user experience, showcasing our dedication to driving digital transformation for our customers and partners.    The upcoming wave is centered around utilizing advanced AI and Microsoft Copilot technologies to enhance user productivity and streamline operations across diverse business applications. These enhancements include intelligent automation, AI-powered insights, and immersive user experiences that are designed to break down barriers between data, insights, and individuals. Watch a summary of the release highlights.    Discover the latest features that empower organizations to operate more efficiently and adaptively. From AI-driven sales insights and customer service enhancements to predictive analytics in supply chain management and autonomous financial processes, the new capabilities enable businesses to proactively address challenges and capitalize on opportunities.    

Updates to Transitions in the Power Platform Communities

We're embarking on a journey to enhance your experience by transitioning to a new community platform. Our team has been diligently working to create a fresh community site, leveraging the very Dynamics 365 and Power Platform tools our community advocates for.  We started this journey with transitioning Copilot Studio forums and blogs in June. The move marks the beginning of a new chapter, and we're eager for you to be a part of it. The rest of the Power Platform product sites will be moving over this summer.   Stay tuned for more updates as we get closer to the launch. We can't wait to welcome you to our new community space, designed with you in mind. Let's connect, learn, and grow together.   Here's to new beginnings and endless possibilities!   If you have any questions, observations or concerns throughout this process please go to https://aka.ms/PPCommSupport.   To stay up to date on the latest details of this migration and other important Community updates subscribe to our News and Announcements forums: Copilot Studio, Power Apps, Power Automate, Power Pages

Users online (1,152)