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

Search on multiple fields: Nesting with Sort and Filter in Gallery.Items formula

I have the below listed formula on Gallery.Items.  I want to search on basically all of the columns, not only "Activity_Name".  Examples include "Description" (a multi-line text field), "Technology_Areas" (a combo box), and "Industry" (a drop-down choice).  Any thoughts on how to integrate that capability into my code?

 

Thanks in advance!

 

-Jake

 

SortByColumns(
Filter(
If(varMyItems, Filter('Engagement Form', 'Created By'.DisplayName = gvCurrentUserName), 'Engagement Form'),
StartsWith(Activity_Name, TextSearchBox1.Text)
),
"ID",
If(SortDescending1, Descending, Ascending)
)

 

6 REPLIES 6
Highlighted
Dual Super User II
Dual Super User II

Hi @JRuss 

 

you will have to add AND(&&) and OR (||) logic to your query

 

Example:

 

SortByColumns(
Filter(
If(varMyItems, Filter('Engagement Form', 'Created By'.DisplayName = gvCurrentUserName && StartsWith(Description && Industry.Value = IndustryDropdown.Selected.Value,descriptionTextBox.Text)), 'Engagement Form'),
StartsWith(Activity_Name, TextSearchBox1.Text)
),
"ID",
If(SortDescending1, Descending, Ascending)
)

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Highlighted

Hi Reza,

 

This did not work.  I have attached a screenshot taken after I cleaned up the column names.  Also, the StartsWith function is included twice?

 

-Jake

Highlighted

Hi @JRuss 

 

Sorry was on a poor wifi network which did not paste the correct format

 

This is your original function

 

SortByColumns(
Filter(
If(varMyItems, Filter('Engagement Form', 'Created By'.DisplayName = gvCurrentUserName && Code), 'Engagement Form'),
StartsWith(Activity_Name, TextSearchBox1.Text)
),
"ID",
If(SortDescending1, Descending, Ascending)
)

 

Just add (below is just an example) to your existing logic

Code = 

StartsWith(Description,descriptionsearchbox.Text ) && Industry.Value = IndustryDropdown.Selected.Value

 

Assuming Industry is a column of type Choice

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Highlighted
Community Support
Community Support

Hi @JRuss ,

Could you please share a bit more about the "Technology_Areas" field and  "Industry" field in your SP List data source? Are they Choice type column?

Durther, do you want the TextSearchBox1 search text to be also searched within "Description" field, "Technology_Areas" field and "Industry" field?

 

Currently, within PowerApps, the StartsWith function could only be used to test whether one Text type column begins with a text value, it could not be used for Complex type column, e.g. Choice, LookUp, Person column type in SP list.

 

As an alternative solution, please take a try with the following workaround:

Please consider modify your formula as below:

SortByColumns(
             Filter(
                      AddColumns('Engagement Form', "IndustryValue", Industry.Value, "Technology_AreasValue", Technology_Areas.Value),
If(varMyItems, 'Created By'.DisplayName = gvCurrentUserName, true), StartsWith(Activity_Name, TextSearchBox1.Text) || StartsWith(Description, TextSearchBox1.Text) || StartsWith(IndustryValue, TextSearchBox1.Text) || StartsWith(Technology_AreasValue, TextSearchBox1.Text) ), "ID", If(SortDescending1, Descending, Ascending) )

Note: Please set the "Data row limits for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App settings of your app. I assume that the "Technology_Areas" field and  "Industry" field are both Choice type column in your 'Engagement Form' data source.

 

Please take a try with above solution, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Highlighted

Hi Reza,

I wasn't able to make this work for some reason.  Any way you can integrate the code for me?

-Jake

Highlighted

Hi Kris,

 

Technology_Areas is a combo box and Industry is a drop-down choice.  Yes I would love it if I could search all of the fields.  I removed the Technology_Areas argument from the StartsWith function in your code (listed below), and while the search appears to be working properly for Description and Industry, after selecting the list item from the gallery, the details never load.  Please refer to the screenshots below.  And thank you in advance!

 

-Jake

 

SortByColumns(
Filter(
AddColumns('Engagement Form', "IndustryValue", Industry.Value, "Technology_AreasValue", Technology_Areas.Value),
If(varMyItems, 'Created By'.DisplayName = gvCurrentUserName, true),
StartsWith(Activity_Name, TextSearchBox1.Text) || StartsWith(Description, TextSearchBox1.Text) || StartsWith(IndustryValue, TextSearchBox1.Text)
),
"ID",
If(SortDescending1, Descending, Ascending)
)

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Community Highlights

Community Highlights

Check out the Power Platform Community Highlights

Top Solution Authors
Top Kudoed Authors
Users online (10,118)