cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Andy_Prog
Resolver I
Resolver I

Counting Items from a SharePoint List to Navigate to another Screen

Hi all,

 

I was wondering if there is a better way to read items in a list from SharePoint.

 

Currently I am reading list data in a Gallery

If(CountRows(BrowseGallery1.AllItems) >= 30, Navigate(fullScreen),
    !IsBlank(LookUp(WorkshopList_1, Title = User().FullName)), Navigate(existScreen),
    CountRows(BrowseGallery1.AllItems) < 30, Navigate(firstDate))

Unfortunately, even when the list is over 30 items it will still navigate to the firstDate screen.

 

Could anyone shed some light on this for me please?

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@Andy_Prog 

So, your formula at this point should be more like this:

If(CountRows(WorkshopList_1) >= 30, Navigate(fullScreen),
    !IsBlank(LookUp(WorkshopList_1, Title = User().FullName)), Navigate(existScreen),
    CountRows(WorkshopList_1) < 30, Navigate(firstDate))

 

Where are you using this formula??

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

15 REPLIES 15
RandyHayes
Super User
Super User

@Andy_Prog 

You are most likely dealing with the delayed nature of the Galleries.  Galleries are special in that they "page" their rows on demand.  So, when the gallery is first displayed, it will perhaps only have a subset of the rows in it.  As you scroll down, it will gather more.

 

You can see this in action if you place a Label on the screen and set the Text property to: CountRows(BrowseGallery1.AllItems)

You will see that number change as you scroll through your list.

 

So, instead of basing your formula on the Gallery allitems, you might consider basing it on the table that the Gallery is based on.

 

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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Thanks for the prompt response @RandyHayes 

 

I was trying to read from the table, or the sharepoint list but I'm unsure of how to approach this.

 

I tried to count the items in the list but I seem to continuously get an error unfortunately. that's why i used the Gallery, maybe a collection would be ideal, not too sure.

 

For example of what I am trying to achieve to avoid delay of the Gallery would look something like this but this doesn't work: CountRows(SharepointList.AllItems)

RandyHayes
Super User
Super User

@Andy_Prog 

What is the Items property of your Gallery?

That is where you can start the journey -  CountRows(yourcurrentItemspropertyformula)

 

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

The Item's property is WorkshopList_1, which is what I am using in the countrows already

 

This is where I got a little confused

RandyHayes
Super User
Super User

@Andy_Prog 

Okay...is WorkshopList_1 your datasource?  Are you saying you originally had that in the formula and it did not work?

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

@RandyHayes 

I have WorkshopList_1 as a list on Sharepoint and connected to the Gallery as a datasource.

 

It's in my formula above, but it works sometimes, but mostly bypasses it and most users can add their names to the list as an item.

 

I have limited the list to 30 and still some users can continue to apply their names to the share point list even it's over 30 items.

RandyHayes
Super User
Super User

@Andy_Prog 

So, your formula at this point should be more like this:

If(CountRows(WorkshopList_1) >= 30, Navigate(fullScreen),
    !IsBlank(LookUp(WorkshopList_1, Title = User().FullName)), Navigate(existScreen),
    CountRows(WorkshopList_1) < 30, Navigate(firstDate))

 

Where are you using this formula??

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

@RandyHayes 

I am using this on the OnSelect formula of a button on my first screen

 

So I don't need to allocate the items in the list in the formula? I've probably over thought my formula.

RandyHayes
Super User
Super User

@Andy_Prog 

That is fine. Was making sure that you weren't doing this in the OnStart.  This way we know that the datasource WorkshopList_1 is available.

 

So have you tried the last formula I provided (or perhaps that is where you started)?

_____________________________________________________________________________________
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.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

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

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,012)