cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Antonio
Helper II
Helper II

how do I fiter data in listbox control using filter

Dear all,

 

I have a browsegallery1 with Items = SortByColumns(Search(Table1; TextSearchBox1.Text; "xxx1"); "xxx1"; If(SortDescending1; Descending; Ascending))

 

 Now I want to add a dropdown element in order to filter the results based on the user selection on the app.

 

Any Idea how can I handle this ?

 

Thanks a lot

1 ACCEPTED SOLUTION

Accepted Solutions
Anonymous
Not applicable

Hello @Antonio,

 

If what matters for you is using the dropdown and you don't need any pre-ordering or pre-filtering before picking an option or you are not using TextSearchBox, just get rid off SortByColumns() and TextSearchBox and use 

 

Filter(Table1;Dropdown1.Selected.Value in 'Table1Column')

or you can also build it like

 

Filter(Table1; Table1Column = Dropdown1.Selected.Table1Column)

works in both ways.

This will just filter all the unordered data by your dropdown selection.

 

Best regards.

View solution in original post

4 REPLIES 4
hpkeong
Community Champion
Community Champion

Hi @Antonio

 

I have just replied to a post here, esp. on the part for Amit.

https://powerusers.microsoft.com/t5/PowerApps-Forum/Multiple-Filters-not-working/m-p/10418#U10418

 

Please cehck if this is OK for you.

 

Have a nice day.

hpkeong

Hello Thanks a lot,

 

I have modified the query to this :

SortByColumns(Search(Filter(Table1;Dropdown1.Selected.Value in 'Table1Column'); TextSearchBox1.Text; "xxx1";"xx2";"xx3"); "xxx1"; If(SortDescending1; Descending; Ascending))

 

and the filter is working.

Now my issue is that the Gallery is pre-filtered , instead I would like to have the gallery filtered only when the user is using the Dropdown1 control.

 

Thanks a lot for your support

Anonymous
Not applicable

Hello @Antonio,

 

If what matters for you is using the dropdown and you don't need any pre-ordering or pre-filtering before picking an option or you are not using TextSearchBox, just get rid off SortByColumns() and TextSearchBox and use 

 

Filter(Table1;Dropdown1.Selected.Value in 'Table1Column')

or you can also build it like

 

Filter(Table1; Table1Column = Dropdown1.Selected.Table1Column)

works in both ways.

This will just filter all the unordered data by your dropdown selection.

 

Best regards.

View solution in original post

hpkeong
Community Champion
Community Champion

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.

hpkeong

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

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (9,946)