cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iwonder
Post Prodigy
Post Prodigy

Empty Gallery vs Still Loading

Thank you for taking the time to read my question.

 

In my app, a user selects a value on screen1, then is taken to screen2 which has a gallery that is filtered on the value selected on screen1.

 

Sometimes there is no data related to the value selected on screen1, so I want to show the user a message on screen. However, in testing, I'm seeing my message every time because the gallery is in fact empty, because the Filter() has not returned any data.... yet. When it does return data, the message is no longer visable.

 

Is there a way I can hide my visual until after the Filter() completes?

I tried the LoadingSpinner.Data but it's too fast for that.

 

I also thought I could put a Timer on the page and delay my visual a few seconds just in case, but that seems silly and may present other issues.

 

Thanks

 

iwonder_0-1632144586548.png

 

1 ACCEPTED SOLUTION

Accepted Solutions

Dataverse should run great as a backend. How long is it taking to bring up your filter result (which appears to be delegable)?

 

Power Apps as a service does not execute everything in one simple sequence. It will delegate your filter to the server, and while that is working it will evaluate other queries and populate control values. It tries to be efficient without upsetting dependencies in the app, which is why Gallery2.AllItems will show blank until the Items property for Gallery2 has completed its query.

 

If the LookUp() doesn't help, I am unsure about more elegant solutions since we have few behavior formulas to work with while a gallery loads. A timer starts to look pretty attractive as an option.

 

Bryan

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

6 REPLIES 6
BCLS776
Super User
Super User

How are you controlling the visibility of this "no results" message - is it off the contents of the gallery, or off the Filter() itself? If you share the code for the gallery Items and the Visible property of the "no results" message, we'll be able to tell.

My guess is that the message's visibility is related to a variable or If() that does not get evaluated until after the Filter() is executed. Instead, you'll want to turn that message off until your Filter confirms no data is returned. It can be handy to base a conditional statement off the fact Filter() returns an empty table when no matching records are found.

Hope that helps,

Bryan

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Hi @BCLS776 , Thank you for your reply.

 

Very sorry, I meant to include the code I am using.

 

I have the image and the button "on top" of the gallery.

 

The gallery is based on a Filter: 

Filter(FreightRates,And(UnloadZone = varUZ,Facility = Text(varSelFacilityCode)))

 

 

The Visibility of the image and the button are: 

IsEmpty(Gallery2.AllItems)

 

If I need to base the visibility of my image and button off the results of the filter, do I need to run the filter twice? Once to populate the gallery and once to check on visibility? Is there a way I can run it once? Even if I filled a collection, and based the image and button visibility off of the collection, I'm thinking I'd get the same result as I'm seeing now.

 

Thanks

You could base the visibility property off of a LookUp(), which will run faster than a Filter() since it only needs to find the first matching record:

IsBlank(
    LookUp(FreightRates,And(UnloadZone = varUZ,Facility = Text(varSelFacilityCode))
)

 

That said, galleries are efficient in that they only load the first 100 records, which should be very quick. Well, unless you are using Excel as a data source - that's a very slow backend. What are you using?

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

Hi @BCLS776 

 

Thanks again for your quick reply.

 

I'm using Dataverse. 

 

I will try the Lookup, but that means I'm running another call. Also, how do you force the LookUp to run before the Filter? If it runs after, I suspect nothing will change.

 

 

Dataverse should run great as a backend. How long is it taking to bring up your filter result (which appears to be delegable)?

 

Power Apps as a service does not execute everything in one simple sequence. It will delegate your filter to the server, and while that is working it will evaluate other queries and populate control values. It tries to be efficient without upsetting dependencies in the app, which is why Gallery2.AllItems will show blank until the Items property for Gallery2 has completed its query.

 

If the LookUp() doesn't help, I am unsure about more elegant solutions since we have few behavior formulas to work with while a gallery loads. A timer starts to look pretty attractive as an option.

 

Bryan

 

_________________________________________________________________________________________
Help the community help more users by choosing to "Accept as Solution" if this post met your needs. If you liked the post and want to show some appreciation, please give it a Thumbs Up.

View solution in original post

...that's kinda what I was thinking too. I'll give the timer a shot.

really appreciate your time and help @BCLS776 

 

have a great day!

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 (2,410)