Hi, im working on a simple parcel tracker app that allows users to record parcel tracking info to a sharepoint list. I'd like to add Gallery that displays the last 3 items scanned in the session so the user can see if they were scanned in correctly. I have done this by using FirstN/LastN and SortColumns. However the issue is that it's using a lot of resoruces as its returning the whole sharepoint list (1.3mb). I'm wondering if there was a better way to do this with variables?
Gallery - Items property:
FirstN(SortByColumns(DataSource, "ID", Descending), 3)
OR
SortByColumns(LastN(DataSource, 3), "ID", Descending)
Solved! Go to Solution.
You could put a filter in as well to limit the results, for example, if you know that you will have items scanned every day you could set the create date to more than yesterday, this will limit the result to last last 24 hours and then return the last 3.
FirstN(SortByColumns(Filter(DataSource,Created > DateAdd(Today(),-1,Days)), "ID", Descending), 3)
Hi @rethc ,
This is really the same thing, but see how it goes for performance
With(
{
wList:
Sort(
DataSource,
ID,
Descending
)
},
FirstN(wList,3)
)
Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.
You could put a filter in as well to limit the results, for example, if you know that you will have items scanned every day you could set the create date to more than yesterday, this will limit the result to last last 24 hours and then return the last 3.
FirstN(SortByColumns(Filter(DataSource,Created > DateAdd(Today(),-1,Days)), "ID", Descending), 3)
Genius!! Thank you - it has drastically dropped the resources to around 5842 bytes.
I've also noticed that a Gallery in another screen is refreshing after a new record is added. How prevent it from refreshing the Datasource when the screen is not active? I have tried setting the visible property to false but it has made no difference.
Gallery1 - Items property:
Filter(DataSource, StartsWith(Title, text_searchbox.Text))
Sorry, i can't understand what you are asking, maybe re read your question and ask it again. The gallery will refresh when a item is edited or added within the app. The only way to stop this is using collections.
Hi C-Papa, i want to prevent a gallery in another screen from refreshing. The default value in my text_searchbox is "" which will bring up all records from the sharepoint site based on my Filter.
Is it possible to put an If statement in the Gallery Item property so that if the textbox value is null then do nothing.
If(text_searchbox.Text="",
Filter(DataSource, StartsWith(Title, text_searchbox.Text)),
Blank()
);
What you are trying to achieve is not possible without a collection. the below video should help you out.
Working with a PowerApps Collection - YouTube
Remember to mark the above answer as a solution to allow others to search and find the correct answer
User | Count |
---|---|
255 | |
110 | |
90 | |
51 | |
44 |