cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
roncam
Level: Powered On

Toggle filter

I have a gallery filter with items = SortByColumns(Filter(Clients, StartsWith(Title,TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

 

the above is working and it gives me all the projects but now I need to add a toggle filter so that from the above result I filter again if the projects are assigned.

 

can you help me on how to do it please ?

 

thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft Employee

Re: Toggle filter

Yes. You can add multiple search/filter criterias. Please try the following:

SortByColumns(Filter(Clients, StartsWith(Title,TextSearchBox1.Text) Or StartsWith(Assigned_To,TextSearchBox1.Text) Or StartsWith(ClientCode,TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))

Note that the formula above will find records where Title, AssignedTo or ClicnetCode starts with a value provided in the TextInput. If you prefer to find records where Title, AssignedTo or ClientCode contain the search value (as opposed to starts with) then your formula will be:

SortByColumns(Filter(Clients, TextSearchBox1.Text in Title Or TextSearchBox1.Text in Assigned_To Or TextSearchBox1.Text in ClientCode), "Title", If(SortDescending1, Descending, Ascending))

Note the "in" operator which allows you to find the records. 

 

21 REPLIES 21
Microsoft Employee

Re: Toggle filter

Hello @roncam,

I assume you want to add a new filter by changing the value of a toggle control. Let's assume that you also want to filter by "Heading" using the value from TextInput2. In this case you can modify your formula as following:

SortByColumns(Filter(Clients, If(Toggle1.Value=true, StartsWith(Title,TextSearchBox1.Text), StartsWith(Heading,TextSearchBox2.Text))), "Title", If(SortDescending1, Descending, Ascending))

roncam
Level: Powered On

Re: Toggle filter

what settings I need to put into the toggle please ?

roncam
Level: Powered On

Re: Toggle filter

my IsAssigned? a calculated formula column returning Yes or No

Super User
Super User

Re: Toggle filter

The filtering is done in the items property of the gallery.

SortByColumns(Filter(Clients, If(Toggle1.Value=true, StartsWith(Title,TextSearchBox1.Text)
&& IsAssigned=“Yes”,StartsWith(Title,TextSearchBox1.Text)), "Title", If(SortDescending1, Descending, Ascending))
Microsoft Employee

Re: Toggle filter

In this case you can use this:

SortByColumns(Filter(Clients, If(isAsigned="Yes", StartsWith(Title,TextSearchBox1.Text), StartsWith(Heading,TextSearchBox2.Text))), "Title", If(SortDescending1, Descending, Ascending))

 

Please double check the value in your "IsAssigned" column to ensure it is really "Yes" and "No" and adjust the formula accordingly.

roncam
Level: Powered On

Re: Toggle filter

instead of the TextSearchBox2.Text can i have a toggle switch for yes or no ?

Microsoft Employee

Re: Toggle filter

Do you mean that you want to filter by a column (Heading in my example) that contains true/false values? If so then something like the following should work:

SortByColumns(Filter(Clients, If(isAsigned="Yes", StartsWith(Title,TextSearchBox1.Text), Heading = Toggle1.Value))), "Title", If(SortDescending1, Descending, Ascending))

roncam
Level: Powered On

Re: Toggle filter

the column is a calculated column returning Yes or No.

 

I have the searchbox searching in the title but then i have a toggle switch that i want to filter again the search on if it is assigned or no

Microsoft Employee

Re: Toggle filter

Is this what you're looking for?

SortByColumns(Filter(Clients, If(Toggle1.Value=false, StartsWith(Title,TextSearchBox1.Text), Lower(isAsigned)="yes", "Title", If(SortDescending1, Descending, Ascending))

If no then can you please provide the respective column names along with types?

Thank you