Hi @Antonio @Anonymous
I copy and paste from the reply I posted for Ami. Hope this is clear.
Hi @AmitLoh-Powerap
Original Text:
In PowerApps example (3-screens autogenerated apps), it always use
- Sortby(Search(.............. Filter(..........)) where the Gallery.Items = TableX
This is OK only for SINGLE Search!
But, I always prefer to have several ways of searching, such as:
- TextInput (as of MS example)
- Sort by Dropdown
- Sort All, Group, etc.
In this case, you have to use:
- Screen.OnVisible = ClearCollect(NewCollection, Filter(OriginalTable, Condition as you wish, ......)) if pre-filter needed, OR
ClearCollect(NewCollection, OriginalTable)...If no pre-filter needed
- Set the Gallery.Items = NewCollection
Now you can have different kind of Seach, by always referring to this NewCollection.
e.g.:
1. ButtonAll.OnSelect = ClearCollect(NewCollection, OriginalTable)...whenver you want to revert back to view ALL
2. InputText1.OnSelect or OnChange = ClearCollect(NewCollection, If(IsBlank(TextInput1.Text), OriginalTable, Filter(OriginalTable, FieldTitleZ = InputText1.Text)))
3. DropDown.OnSelect or OnChange = ClearCollect(NewCollection, Filter(OriginalTable, FieldTitleX = or exactin or in Dropdown1.Selected.Result)), where the Dropdown can be Dropdown1.Items = Distinct(OriginalTable, FieldTitleX)
4. Others where the syntax is identifical of Dropdown.
You can observe here that: All Filtering, Dropdown, Input Text will eventually being ClearCollect ino NewCollection, where NewCollection is the items for Gallery.
Learn Tutorial has never mentioned this method because it assumes that most of the time, we only fitler ONE WAY, but the logic is the same. I am sure you are aware of this but never try or maybe I am wrong.
Hope this helps.