cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarlBurg
New Member

Trying to filter based on Status of specific Item

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

1 REPLY 1
v-xida-msft
Community Support
Community Support

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:

Filter function

 

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,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,393)