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
Solved! Go to Solution.
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
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
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?
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
...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!
I posted this in a similar thread, but here is how I resolved the issue with my "No Results" message displaying while the gallery was still loading. You can use a label for your "No Results" message, but I used a button so users could reset a filtered gallery.
I added a timer control to the screen (Timer1) and set its Duration property to 5000 (five seconds). For the "No Results" message, I used a button (btnNoResults) and set its Visible property to:
IsEmpty(GalleryName.AllItems) && Timer1.Value > 3000
With this approach, the "No Results" button won't be visible unless the gallery is empty AND three seconds have elapsed. This worked for my dataset.
To reset the gallery (and hide the "No Results" button while the gallery loaded items again), I created a context variable for btnNoResults' OnSelect property:
UpdateContext({varStartTimer:false}); UpdateContext({varStartTimer:true}); Reset(GalleryName)
Then, I set the Start property for Timer1 to that variable:
varStartTimer
For Timer1, ensure the Repeat property is false and AutoStart is true.
This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.
Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.
User | Count |
---|---|
197 | |
69 | |
49 | |
43 | |
20 |
User | Count |
---|---|
257 | |
124 | |
83 | |
76 | |
69 |