
Announcements
Hi i'm trying to Filter Items with the specific status when they press a Button.
So if they press the Button 'New' only the Items with the Status 'New' should show up, the same should happen with the other three Buttons.
I'm using a Globalvariable for this which is called "ExpensesStatus".
I just don't understand how to filter it.
Current Gallery Items
SortByColumns(Filter(Expenses, StartsWith(Title, TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
Current Button
Set(ExpensesStatus,"New")
Globalvariable
Set(ExpensesStatus,"New"); Set(ExpenseSorting,Descending); ClearCollect(NewReports,Filter(Expenses,Status.Value = "New").ID); ClearCollect(ApprovedReports,Filter(Expenses,Status.Value = "Approved").ID); ClearCollect(ExportedReports,Filter(Expenses,Status.Value = "Exported").ID); ClearCollect(DeclinedReports,Filter(Expenses,Status.Value = "Declined").ID); Refresh(Expenses)
Thanks
HI @KarlBurg ,
Could you please share a bit more about your scenario?
Do you want to filter your Gallery items based on which button do you press? And display all records within your Galley in default?
Based on the needs that you mentioned, I have made a test on my side, please take a try with the following workaround:
Set the OnSelect property of the "New" button to following:
Set(ExpensesStatus,"New")
Set the OnSelect property of the "Exported" button to following:
Set(ExpensesStatus,"Exported")
Set the OnSelect property of the "Approved" button to following:
Set(ExpensesStatus,"Approved")
...
Set the Items property of the Gallery to following:
If( IsBlank(ExpensesStatus), SortByColumns(
Filter(Expenses, StartsWith(Title, TextSearchBox1.Text)),
"Title",
If(SortDescending1, Descending, Ascending)
), SortByColumns(
Filter(
Expenses,
StartsWith(Title, TextSearchBox1.Text),
Status.Value = ExpensesStatus
),
"Title",
If(SortDescending1, Descending, Ascending)
) )
More details about Filter function in PowerApps, please check the following article:
In addition, if you want to remove the Status filter condition from your Gallery, you could consider take a try to add the following formula within the OnSelect property of the "Refresh" icon button to following:
Set(ExpensesStatus, Blank())
when you click "Refresh" icon button, all available records would show up within your Gallery again.
Best regards,