web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to filter using co...
Power Apps
Unanswered

How to filter using combobox

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hello, 

 

I am working on a "Book a Room" app. I am trying to filter a gallery called "RoomsGallery" connected to a list called "AllRooms" using a combobox called "LocationBox." The building names in the gallery only contain an abbreviation of the city's name. I want to make it so that when I select a certain building location, it will filter the gallery based on that. For example if I select "Washington, DC" I would want the gallery to show only the rooms that start with "DC"

 

How do I go about doing that?

Categories:
  • Brian Dang Profile Picture
    3,976 on at

    Hi @Anonymous,

    It sounds like you want to use a ComboBox to filter a Gallery. 

     

    Given your requirements, the solution to this is likely something you do within the table you hook up to the ComboBox. You will want to provide the full name and abbreviation of the location in your table.

     

    IdFullNameAbbreviation
    1Washington, DCDC
    2CaliforniaCA
    3WashingtonWA

     

    The ComboBox allows you to show the column you want--in your case you want to show the FullName as the DisplayField. But what you select in the ComboBox is a record; this means that selecting California is really selecting all the information in the record:

    {Id: 1, FullName: "California", Abbreviation: "CA"}

    So instead of attempting to filter your gallery based on the full name of the location, you filter it based on its corresponding abbreviation:

    Filter(datasource, location=ComboBox.Selected.Abbreviation)

    This means, "Filter the datasource where the location is equal to the abbreviation that is selected from the ComboBox."

     

    Let me know how it goes.

     

    Mr. Dang

    ________

  • v-monli-msft Profile Picture
    Microsoft Employee on at

    Hi @Anonymous,

     

    Like @mr-dang suggested, when you select one value from combo box, you are selecting a record. 

     

    I want to know what are the items in your ComboBox? Is "Washington, DC" 2 items that already selected or is it one? If you only have one item selected each time to filter the gallery, then you do not need to use a combo box, you could just use a dropdown control.

     

    If what you need is truly a combo box, and you want to filter the gallery according to multiple items selected in combo box, then in addition to @mr-dang's suggestion, the formula of filtering with combo box should be something like:

    Filter(
    datasource,
    First(LastN(ComboBox1.SelectedItems,1)).Abbreviation in location && First(LastN(ComboBox1.SelectedItems,2)).Abbreviation in location && First(LastN(ComboBox1.SelectedItems,3)).Abbreviation in location && ... )

    Regards,

    Mona

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Error Msg.PNGLocation Box.PNGTable.PNGThere is a built in variable called "Location." However, I get an invalid arguement message when I use it. Am I supposed to create a new variable or is there something wrong with my code pictured?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at
    @v-monli-msft Any news? Cause I got exactly the same issue
  • orbis_admin Profile Picture
    12 on at

    @Anonymous, I was able to do it like this (using example above where 'Abbreviation' is a column in 'datasource'):

     

    Filter(
    datasource,
    Or(Abbreviation = First(LastN(ComboBox1.SelectedItems,1)).Value,

    Abbreviation = First(LastN(ComboBox1.SelectedItems,2)).Value,

    Abbreviation = First(LastN(ComboBox1.SelectedItems,3)).Value,
    ...
    )

  • knsrinath Profile Picture
    527 on at

    Hi

    I have a data in Sharepoint List in one Column. I need to do ComboBox Filter based on Start with 4 letters as shown in picture.

     

    knsrinath_0-1623301779752.png

     

    Request you help me to get as I required.

     

     

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 342 Super User 2026 Season 2

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard