Skip to content

Search power apps gallery from CDS based on multiple inputs

In this post, I’m focusing on how to search galleries based on inputs from multiple controls.

In the below example, I have added a textbox against the “City” label, named “City”.

Another textbox named “Phone”.

A radio button named “Radio1

A gallery named “Gallery2”.

Now in the gallery I’ll filter the CDS Contacts with input in City, Phone and Radio1.

I have added below code for this scenario.

In this scenario, if city and phone contains data and radio button is equal to owner, 

If(

    !(City.Text = “”) && !(Phone.Text = “”) && Radio1.Selected.Value = “Owner”,

It will search for all three criteria where the “Job title” is equal to owner and displays the result in the gallery.

    Search(

        Filter(

            Contacts,

            ‘Job Title’ = “Owner”,

            StartsWith(

                ‘Address 1: City’,

                City.Text

            )

        ),

//Here it is searching the data using one text box in multiple fields

        Phone.Text,

        “mobilephone”,

        “telephone1”

    )

)

Please find the complete code below

If(

    !(City.Text = “”) && !(Phone.Text = “”) && Radio1.Selected.Value = “Owner”,

    Search(

        Filter(

            Contacts,

            ‘Job Title’ = “Owner”,

            StartsWith(

                ‘Address 1: City’,

                City.Text

            )

        ),

        Phone.Text,

        “mobilephone”,

        “telephone1”

    )

)

Published inPower Apps Canvas