cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iagosalvadori
Helper I
Helper I

Count number of Rows Gallery doesn´t work

Hi everyone, I created a label in my application that counts the records in a data source:

 

 

If(
    CountRows(Gallery6.AllItems.Título) = 0;
    "0";
    CountRows(Gallery6.AllItems.Título)
)

 

 

 However, counting only works up to 100 records, how do I change this? I know that on the datasource I have 300 records...

I can´t count directly with my data source, because this label changes according to the filters (dropdown, combox, etc.)

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@iagosalvadori 

This is a bit of a hack that I use for that scenario.  

You need to find out how many rows are in your Gallery first by alternate means.  So, if you have an Items property of ListA for example, you would need to find out how many rows are in that with a CountRows.

Now, you need something to kick off.  Depending on your app design, one choice is to have a local variable set OnVisible of the screen - let's say UpdateContext({lclScrollGallery:true})

Now add a toggle to the screen.  In the Default property set it to lclScrollGallery then in the OnCheck action, set the formula to Select(yourGallery, <theNumberOfRowsInYourDataSource>)  - that value you would have derived elsewhere.  Then followed by a Select(yourGallery, 1) which will return it to the top. Follow that with an UpdateContext({lclScrollGallery:false}) 

So, your OnCheck action will be this:

Select(yourGallery, <rowCountForItems>);
Select(yourGallery, 1);
UpdateContext({lclScrollGallery:false})

I am doing the above from memory, so hopefully my mind is working properly today.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

6 REPLIES 6
rsaikrishna
Community Champion
Community Champion

@iagosalvadori 

 

The gallery does not load all the items from SharePoint list for the first time. As you scroll the gallery down, the items will be loaded on demand. First batch 100, next another 100 and so on.

 

To get complete count, you should use the data source of the gallery. It may be direct SharePoint list or filtered list items.

 

Regards

Krishna Rachakonda

If this reply helped you to solve the issue, please mark the post as Accepted SolutionMarking this post as Accepted Solution, will help many other users to use this post to solve same or similar issue without re-posting the issue in the group. Saves a lot of time for everyone.
RandyHayes
Super User
Super User

@iagosalvadori 

Firstly, consider changing the formula to the following:

CountRows(Gallery6.AllItems)

You don't need to have the extra If statement to show the zero.

Next, the Gallery will only "load" so many records.  See if your label changes as you scroll to the bottom of the Gallery.  This will confirm that.  In which case, you can have your app select the last item in your Gallery (and then select the top) automatically, this will load them all and your count should be correct.

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi @RandyHayes , thank you.

 

The label changes as I roll to the bottom. How can I select the last record from the Gallery? Thank you.

RandyHayes
Super User
Super User

@iagosalvadori 

This is a bit of a hack that I use for that scenario.  

You need to find out how many rows are in your Gallery first by alternate means.  So, if you have an Items property of ListA for example, you would need to find out how many rows are in that with a CountRows.

Now, you need something to kick off.  Depending on your app design, one choice is to have a local variable set OnVisible of the screen - let's say UpdateContext({lclScrollGallery:true})

Now add a toggle to the screen.  In the Default property set it to lclScrollGallery then in the OnCheck action, set the formula to Select(yourGallery, <theNumberOfRowsInYourDataSource>)  - that value you would have derived elsewhere.  Then followed by a Select(yourGallery, 1) which will return it to the top. Follow that with an UpdateContext({lclScrollGallery:false}) 

So, your OnCheck action will be this:

Select(yourGallery, <rowCountForItems>);
Select(yourGallery, 1);
UpdateContext({lclScrollGallery:false})

I am doing the above from memory, so hopefully my mind is working properly today.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!
iagosalvadori
Helper I
Helper I

Thanks @RandyHayes , it's working fine

Thank you so much for the advice. Its a big help. Stay safe always.

Helpful resources

Announcements
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Difinity Conference 2022

Difinity Conference 2022

Register today for two amazing days of learning, featuring intensive learning sessions across multiple tracks, led by engaging and dynamic experts.

European SharePoint Conference

European SharePoint Conference

The European SharePoint Conference returns live and in-person November 28-December 1 with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Power Apps Ideas

Changes to Ideas Coming

We are excited to announce a new way to share your ideas for Power Apps!

Top Solution Authors
Top Kudoed Authors
Users online (2,192)