Skip to main content

Notifications

Power Apps - Building Power Apps
Unanswered

Search combined with multiple fields - OnClick of Search button

(0) ShareShare
ReportReport
Posted on by 195

I have achieved custom search functionality for single fields using formula.

OnChange of Textinput - UpdateContext({searchTerm:TextInput1.Text })

In Gallery I have populated search results using Below formula.

Items - If(searchTerm <>"",Search('DataSource',searchTerm,"Event")

 

However, if user keys-in search keyword in multiple fields at sametime, may i know how to make search work. Screenshot below

 

Img2.PNG

 

 

Categories:
  • v-xida-msft Profile Picture
    v-xida-msft on at
    Re: Search combined with multiple fields - OnClick of Search button

    Hi @Kumar9024021 ,

    Could you please share a bit more about your scenario?

    Do you want to search your Gallery Items based on multiple search keywords typed within the "Search Request" part?

     

    If you want to search your Gallery Items based on multiple search keywords typed within the "Search Request" part, I afraid that the single one searchTerm variable could not achieve your needs.

     

    As an alternative solution, I think the combination of If function and Filter function could achieve your needs. I have made a test on my side, please consider take a try with the following workaround:

    Set the Items property of the Gallery to following:

    Filter(
     'DataSource',
     If(
     IsBlank(EventNameTextBox.Text),
     true,
     EventNameTextBox.Text in Event
     ),
     If(
     IsBlank(SubmittedByTextBox.Text),
     true,
     SubmittedByTextBox.Text in 'Submittd By' // If the 'Submitted By' is a Person colum (System field in SP list) in a SP list, please type SubmittedByTextBox.Text in 'Submittd By'.DisplayName here
     ),
     If(
     IsBlank(EventFtomDTPicker.SelectedDate),
     true,
     'Event From Dt' = EventFtomDTPicker.SelectedDate
     ),
     If(
     IsBlank(EventLocationTextBox.Text),
     true,
     EventLocationTextBox.Text in 'Event Location'
     ),
     If(
     IsBlank(EventOrganizerTextBox.Text),
     true,
     EventOrganizerTextBox.Text in 'Event Organizer' // If the 'Event Organizer' is a Person column in a SP list, please type EventOrganizerTextBox.Text in 'Event Organizer'.DisplayName here
     ),
     If(
     IsBlank(StatusTextBox.Text),
     true,
     StatusTextBox.Text in Status // If the Status is a Choice type column in a SP List, please type StatusTextBox.Text in Status.Value here
     ),
     If(
     IsBlank(EventToDatePicker.SelectedDate),
     true,
     'Event To Date' = EventToDatePicker.SelectedDate
     ),
     If( // If there is no field related to the PageSizeDropdown box existed in your data source, please ignore this If formula part
     IsBlank(PageSizeDropdownBox.Selected.Value),
     true,
     'Page Size' = PageSizeDropdownBox.Selected.Value
     )
    )

     

    If you want to display the search results within the Gallery after you click the "Search" button, please consider take a try with the following workaround:

    Set the OnSelect property of the "Search" button to following:

    ClearCollect(
     FilterResults,
     Filter(
     'DataSource',
     If(
     IsBlank(EventNameTextBox.Text),
     true,
     EventNameTextBox.Text in Event
     ),
     If(
     IsBlank(SubmittedByTextBox.Text),
     true,
     SubmittedByTextBox.Text in 'Submittd By' // If the 'Submitted By' is a Person colum (System field in SP list) in a SP list, please type SubmittedByTextBox.Text in 'Submittd By'.DisplayName here
     ),
     If(
     IsBlank(EventFtomDTPicker.SelectedDate),
     true,
     'Event From Dt' = EventFtomDTPicker.SelectedDate
     ),
     If(
     IsBlank(EventLocationTextBox.Text),
     true,
     EventLocationTextBox.Text in 'Event Location'
     ),
     If(
     IsBlank(EventOrganizerTextBox.Text),
     true,
     EventOrganizerTextBox.Text in 'Event Organizer' // If the 'Event Organizer' is a Person column in a SP list, please type EventOrganizerTextBox.Text in 'Event Organizer'.DisplayName here
     ),
     If(
     IsBlank(StatusTextBox.Text),
     true,
     StatusTextBox.Text in Status // If the Status is a Choice type column in a SP List, please type StatusTextBox.Text in Status.Value here
     ),
     If(
     IsBlank(EventToDatePicker.SelectedDate),
     true,
     'Event To Date' = EventToDatePicker.SelectedDate
     ),
     If(
     IsBlank(PageSizeDropdownBox.Selected.Value),
     true,
     'Page Size' = PageSizeDropdownBox.Selected.Value
     )
     )
    )

    Then set the Items property of the Gallery to following:

    FilterResults

     

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

     

    Best regards,

  • yashag2255 Profile Picture
    yashag2255 24,442 on at
    Re: Search combined with multiple fields - OnClick of Search button

    Hey @Kumar9024021 

     

    If you want to search the entered keyword in multiple fields, then you can update the query as:

    If(searchTerm <>"",Search('DataSource',searchTerm,"Event","Column2","Column3")

    This way you can add multiple columns for searching the searchTerm.

    Note: Currently this is triggered on change of text input, but in case you want to only refresh the result when the search button is clicked, please remove the expression from OnChange property of the text input control and place it on the OnSelect property of the button control.

    If this, differs, please share more details about the implementation, maybe through an example.

     

    Hope this Helps!

     

    If this reply has answered your question or solved your issue, please mark this question as answered. Answered questions helps users in the future who may have the same issue or question quickly find a resolution via search. If you liked my response, please consider giving it a thumbs up. THANKS!

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,580

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,909

Leaderboard