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

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

View solution in original post

Text Property of Button:

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

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

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)

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

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

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

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

 

Your brackets are all messed up

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

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)

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

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")

---------------------------------------------------------------------------------------------------------------------------


Was I helpful? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. It will help other users to find it faster.

follow me on Twitter @zmansuri123,
connect with me on LinkedIn from Here

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
Microsoft 365 Conference – December 6-8, 2022

Microsoft 365 Conference – December 6-8, 2022

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.

Top Solution Authors
Top Kudoed Authors
Users online (1,630)