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

How to Add a Drop Down Menu to a Functional Search to Restrict Results?

I have a functional Power App that displays a SharePoint list containing project data. I have a functional search field that searches three columns (Pursuit-Name, SFDC-ID, & Bid-Manager). I have added a drop down menu to further restrict search results based on the SharePoint created date. The SharePoint list only contains 2019 and 2020 projects and therefore the drop down will contain three items (all years, 2020, 2019).

How can I incorporate this drop down menu to work with the existing search function to further restrict the search results? 

 

My gallery is displaying the SP List data and the Items property contain the code shown below. I have one text input control that allows user to search either by Pursuit-Name, SFDC-ID, or Bid-Manager. Any recommendations are greatly appreciated.

 

SortByColumns(
  Filter(
    collTeamsSites, StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ) 
  ) , "Title" 
)

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: How to Add a Drop Down Menu to a Functional Search to Restrict Results?

SortByColumns(
Filter(
collTeamsSites,
Year(Created)= Year( dropdownSiteCreatedYr.Selected.Value)&&
(StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ))
),
"Title"
)

View solution in original post

5 REPLIES 5
Highlighted
Community Champion
Community Champion

Re: How to Add a Drop Down Menu to a Functional Search to Restrict Results?

Try

SortByColumns( Filter( collTeamsSites, StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ) ,YearColumn=Dropdown1.Selected.Value) , "Title" )

 

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

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Helper V
Helper V

Re: How to Add a Drop Down Menu to a Functional Search to Restrict Results?

Thanks @eka24  for the quick response!  I think your solution is close. I left out one detail. The SP List date created column contains the created date in the following format:  August 21, 2019

I have the default property of the dropdown defaulting to 2020. when Power App first loads. 

 

// Won't work since 'Created' date is in August 21, 2019  format

SortByColumns( Filter( collTeamsSites, StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ), 'Created' = Dropdown1.Selected.Value ) , "Title" )

 

  1. Since 'Created' is a SP date column/data type, how would I convert the Dropdown1.Selected.Value to just produce the year like yyyy?
  2. Also, will the gallery always update the search results when the dropdown is changed or do I have to add code to the "OnChange" property?

Please advise.

Highlighted
Community Champion
Community Champion

Re: How to Add a Drop Down Menu to a Functional Search to Restrict Results?

Try

SortByColumns( Filter( collTeamsSites, StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ), Text(Created,ShortDate)= Text(Dropdown1.Selected.Value,ShortDate ) , "Title" )

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

If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

Highlighted
Helper V
Helper V

Re: How to Add a Drop Down Menu to a Functional Search to Restrict Results?

Thank you @eka24 for your response. Sorry for the slow reply but I got into another project.  

 

Your post put me on the right track so now I have this which works. I have to extract just the year.  Is there a better/shorter way to do this? 

 

SortByColumns(
Filter(
collTeamsSites,
Right( Text( Created, ShortDate ), 4 ) = Right( Text( dropdownSiteCreatedYr.Selected.Value, ShortDate ), 4 ) &&
(StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ))
),
"Title"
)

Highlighted
Community Champion
Community Champion

Re: How to Add a Drop Down Menu to a Functional Search to Restrict Results?

SortByColumns(
Filter(
collTeamsSites,
Year(Created)= Year( dropdownSiteCreatedYr.Selected.Value)&&
(StartsWith( 'Pursuit-Name', txtSearch.Text ) || StartsWith( 'SFDC-ID', txtSearch.Text ) || StartsWith( 'Bid-Manager', txtSearch.Text ))
),
"Title"
)

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

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