the previous speaker has already suggested the appropriate solutions for PowerFx. However, I would already filter the basic data outside, according to the maximum values. In my opinion, this is not part of the app logic. If you have the option, filter the data in the data memory or in the data processing tool. Here you usually have more tools for data processing. You can now integrate the filtered list into your gallery and then create an input field. Now you can use the Search() function or the Filter() function in the Items property of the Gallery.
This way you don't have any logic in your app that has to filter large amounts of data. This is cleaner and performs better.
Yours sincerely Felix Hois