Hi @MIA27 ,
Short answer is that you should apply the filter, but this may not always give you the results you expect.
Hopefully I can explain this without completely confusing you as some may be lost in translation...so I'll try avoid the complex stuff and stick to the basics;
Galleries connect to tables that come from one of two places;
- an external data source (like SharePoint or SQL), or
- from inside Power Apps (like a collection or a table output from a command).
For performance reasons, galleries behave differently when connected to an external source as opposed to when they are connected to a collection or a table inside PowerApps.
For example, if a gallery is connected directly to a SharePoint list (without a filter function), the gallery knows there is data transfer involved in the query, so it will try and be efficient by fetching only the first 100 rows of data to reduce performance impact.
Obviously if your source has less than 100 rows, this doesn't matter, but if it has more, the gallery will fetch the next 100 only if you continue to scroll down to the end of the gallery (you'll see the query dots run on top of the screen, then the scroll bar will jump and you'll have 100 more rows in your gallery) - if you continue scrolling the gallery will eventually get to the end of your data, even if you have 10000 rows in your source.
To get the reset working, the Default: record must exist in the current gallery dataset when reset() is called.
The reason your reset doesn't work is that your Default: expression record is at the end of the dataset, and this doesn't exist in the gallery, until all the rows have been loaded - which only happens when you scroll to the end.
So the quick solution here is probably to apply your filter function, as this automatically fetches the maximum number of rows allowed by your data row limit, instead of just the first 100. Provided the filter result does not exceed your data row limit, it will work. As soon as the filter result exceeds your data row limit, and your Default: points to a record beyond this limit, (which Last() will always do) there will be a mismatch between the Last() result applied to the dataset and the Last() result in the gallery items. This is why we apply the filter() to the last function as well, so that the resulting record is inside the same dataset returned by Items:
Note: Now, I have to warn you - there are always data row limit and delegation considerations that will affect this experience - so when your source has a large amount of rows, things start behaving quite differently - but it may be a bit much to explain for now, so I've included some links to read when you can - but just bear in mind things start to change when you have a large amount of data in your source - say > 500 rows. You can change your data row limit in your app settings to 2000, but that's the max. Eventually, you'll have to figure out the best way to filter large data sets - but for now....
The short-term solution is to try and make sure your gallery contains all the rows you're going to need up front.
You can do this by specifying a filter that only fetches the rows you need, and just make sure that same filter is applied to your Default: Last() function.
You can also Collect() the data into a collection and connect your gallery to that instead, using the collection also in your Default: Last() function.
Whatever way you choose to go about it, just remember that the resulting record from Default: must exist inside the gallery at the time of reset. When you're connecting to an external source with more than 100 rows or more than your data row limit - this may not always be the case.
Hope this helps explain somewhat - sorry if sounds complicated - but it is a little complicated 😁
Kind regards,
RT