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

Search and Filter on Items

Hi. 

I have the following code to search my gallery. The code is on the Items Action of the gallery. 

 

Search(
'DataSourceName)',
SearchBox.Text,
"Name"
)

 

This works fine. 

 

I would like to also include a filter on the items action to say Filter(DataSourceName, Name.Email = User().Email)

 

A) How do i include both the Search and the filter on the same items action. 

I tried the below, but it doesnt like it 

 

Search(
'DataSourceName)',
SearchBox.Text,
"Name"
) & Filter('DataSourceName,'Name'.Email = User().Email))

 

B) Once the filter is applied and step A above is working. 

How can i create a button to say, clear the filter so every item is shown. 

 

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions

If(varFilter,
Search(
Filter(
Sort(
DataSourceName
,"Name",
Ascending
),
'Owner'.Email = User().Email
),
SearchBox.Text,
"Name"
),DataSourceName)

 

Your brackets are all messed up

View solution in original post

Text Property of Button:

If(varFilter,"View My","View All")

View solution in original post

11 REPLIES 11
zmansuri
Super User
Super User

Search(Filter(DataSourceName, Name.Email = User().Email),SearchBox.Text,"Name")

 

Add a button. OnClick of button:

Set(varFilter,!varFilter);

Gallery Item code:

If(varFilter,Search(Filter(DataSourceName, Name.Email = User().Email),SearchBox.Text,"Name"),DataSourceName)

If(
varFilter,
Search(
Filter(
Sort(
'DataSourceName)',
Name,
Ascending
),
'Owner'.Email = User().Email
),
SearchBox.Text,
"Name"
)
)

 

There is no error with the code, but the gallery is not returning anything back?. If i remove the If(
varFilter, IT Works. 

But i need the filter and i need the button to clear the filter?

 

Any ideas?

Show Your button on Click code

If(varFilter,
Search(
Filter(
Sort(
DataSourceName
,"Name",
Ascending
),
'Owner'.Email = User().Email
),
SearchBox.Text,
"Name"
),DataSourceName)

 

Your brackets are all messed up

Set(varFilter,!varFilter); my onselect button code. 

Screen OnVisible:

Set(Set(varFilter,true);

Button OnClick:

Set(varFilter,!varFilter);

Gallery Item:

If(varFilter,
Search(
Filter(
Sort(
DataSourceName
,"Name",
Ascending
),
'Owner'.Email = User().Email
),
SearchBox.Text,
"Name"
),DataSourceName)

Thank you very much. That sorted it. 

 

One last question, on the button - how can i make the text dynamic. 

E.g. when i press the button, it filters the gallery - so i would like the button to say View All. 

Then when View All is shown, i would like the button text to display, View My 

 

Is that possbile?

Text Property of Button:

If(varFilter,"View My","View All")

Thank you very much. You have been a great help. 

These little helpful tips go a long way in helping me (and others) in building robust solutions. 

You are a credit to the community. 

Thank you once again. 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,552)