cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
pmwhelan
Helper V
Helper V

Filter a Gallery?

Hi

I have a Gallery "Gallery1" and I have a connection to a SharePoint List "ProjectVertigo"

I put a textbox and a button on my page.

I would like the gallery to filter by the items that match my textbox.

 

I try to do this in the OnSelect of the Button

Filter(ProjectVertigo, TextInput1.Text in ProjectVertigo.Title)

But nothing happens?

Thanks

P

1 ACCEPTED SOLUTION

Accepted Solutions
Sundeep_Malik
Community Champion
Community Champion

Hey @pmwhelan 

 

Do this:

 

On the button's on select:

 

UpdateContext({gFilter:TextInput1.Text})

 

Gallery Items property:

 

If(
IsBlank(gFilter),
ProjectVertigo,
Filter(
ProjectVertigo,
Title=gFilter
)

)

 

Take another button, name it as unfilter:

 

Set its on select property:

 

UpdateContext({gFilter:Blank()})

View solution in original post

9 REPLIES 9
Sundeep_Malik
Community Champion
Community Champion

Hey @pmwhelan 

 

I did a similar scenario in my gallery, and I wrote 

 

Filter(ProjectVertigo, TextInput1.Text = Title)

 

or

 

Filter(ProjectVertigo, TextInput1.Text in Title)

 

No need to write

ProjectVertigo.Title

Just Title would do, as you have already written the data source outside.

pmwhelan
Helper V
Helper V

@Sundeep_Malik 

Thanks for the help.

 

I tried

Set(vSearch, "Ready");
Filter(ProjectVertigo, tbSearch.Text = Title);
Set(vSearch, "Done");

I have vSearch as the Text of a Label (just to make sure it runs)

 

Still the gallery doesn't change at all.

 

Thanks

SanshubhLubal
Helper V
Helper V

You can do Something like this.

 

Filter(
    ProjectVertigo,
    StartsWith(
        Title,
        TextInput1.Text
    )
)

 Use Startwith function to search in powerapps. If this code solves the problem mark as solved.

Tried that but it's not filtering the Gallery.

Do I need to refresh the Gallery after Filtering on the SharePoint List "ProjectVertigo"

Sundeep_Malik
Community Champion
Community Champion

@pmwhelan 

 

Can you share some screenshots to help, need do see what you are trying to do. 

no, you don't need to refresh to filter Gallery. It'll filter automatically. Just write that code on Gallery's Item property. 

pmwhelan
Helper V
Helper V

Of course 🙂

The Items of the Gallery is ProjectVertigo

The OnSelect of the Button is

Set(vSearch, "Ready");
Filter(
ProjectVertigo,
StartsWith(
Title,
tbSearch.Text
)
);
Set(vSearch, "Done");

Chitrakant27
Resolver II
Resolver II

Hi @pmwhelan ,

Apply code on gallery item-

Sortbycolumn(Filter(ProjectVertigo,Startwith(Title,Textinput1.text)),"ID",Descending )

 

     or 

Filter(ProjectVertigo,Startwith(Title,Textinput1.text)

 

Thanks,

Chitrakant27

Sundeep_Malik
Community Champion
Community Champion

Hey @pmwhelan 

 

Do this:

 

On the button's on select:

 

UpdateContext({gFilter:TextInput1.Text})

 

Gallery Items property:

 

If(
IsBlank(gFilter),
ProjectVertigo,
Filter(
ProjectVertigo,
Title=gFilter
)

)

 

Take another button, name it as unfilter:

 

Set its on select property:

 

UpdateContext({gFilter:Blank()})

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (5,493)