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 / Filtering by selected ...
Power Apps
Unanswered

Filtering by selected Items from listboxes inside a gallery?

(0) ShareShare
ReportReport
Posted on by 6

So I wanted to make a dynamic way to search through a set of skills pulled from my azure sql database. The data is represented with 3 tables.

My skill table has a relation to my skill type table, and my skill type table has a relation to my categories table. Basically, a skill has a type and a types has a category.

I've created a gallery which items are categories, and each item has its own gallery which items are Skill types filtered by categoryID. The Skill Type gallery has Listboxes inside of them that displays skills filtered by SkillTypeID. All this works, and each listbox has the right skills shown inside them.

The problem is, when I try to view the selecteditems of the listboxes, I don't get a thing. The initial listbox is named ListBox5, and all other listboxes are created dynamically from it. So I try to get all the selected items SkillID with 'ListBox5.SelectedItems.SkillID ' and get nothing at all.

Is there anyway to get selecteditems from listboxes in galleries?

Categories:
  • v-micsh-msft Profile Picture
    Microsoft Employee on at

    Hi @DrBread,

     

    Which control that you used to display the selecteditems of the ListBox?

    Listbox.selecteditems would return a table, so if you would like to display it, then we need to add a Gallery control.

    The formula specified with the items property of the added gallery should be:

    SkillTYpeGallery.Selected.ListBox.SelectedItems

    48.PNG

    Gallery.selected is used to identify the SkillTypeID, once generated, the Added gallery would display the Sills record associated with the SkillTypeID.

    Please post back if you have any further quesitons.

    Adding some reference:

    List Box control in PowerApps

    Understand data forms in Microsoft PowerApps

    Gallery control in PowerApps

    Regards,

    Michael

  • DrBread Profile Picture
    6 on at

    Hi v-micsh-msft,

    I am using a gallery to display the selected items. Even with the code you demonstrated, I still get nothing from the selected items. It is really strange because if I pull the skill type gallery out of the categories gallery, it works.

    I think there is an issue of nesting the gallerys. Not sure why or how it is happening. I've tested it now in multiple ways, and if the galleries are nested, I can't get the the selected items from the listbox inside.

    I've tried this code aswell, CategoriesGallery.Selected.TypesGallery.Selected.SkillsListBox.SelectedItems

    Maybe I am missing something, or maybe I should just try to implement this in a different way, I just wanted it to be dynamic so if I add more categories or types in the future I won't have to rebuild this.

    Thanks

  • DrBread Profile Picture
    6 on at

    I just wanted to let you know I have found a sort of work around.

    Instead of displaying the selected Items directly, I decided I will create a Collection to collect what is selected on the listbox when a change happens to the listbox.

    So OnChange of the SkillListBox, I did this:

    If( !(SkillListBox.Selected.SkillID in CacheSearchSelected.SkillID), Collect( CacheSearchSelected, SkillListBox.Selected)); RemoveIf(CacheSearchSelected, SkillID in Filter(Filter(CacheSkills, Skill_TypeID = ThisItem.Skill_TypeID), !(SkillID in SkillListBox.SelectedItems.SkillID)).SkillID)

     

    SkillListBox is my listboxes
    CacheSearchSelected is my Collection of selected items
    CacheSkills is all of the skills
    ThisItem is a skill type gallery item

    I can tell the formula is a mess but it works, Ill try to explain it

    First thing I check is if the selected skills are not already in the CacheSearchSelected collection and if not, add them. 

    Next thing I need to do is remove skills from the CacheSearchSelected collection when someone removes a selected item, In order to know what to remove, I had to first get filter the list of skills that  are currently in the list box, and then filter out the selected items of that list box. This leaves me with a list of only the skills that aren't selected for that list box, and I can remove those skills from my CacheSearchSelected collection.

    Anyway, thats how I worked around it, I'd rather not have to do all that though 😛

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 236 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 207 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 169

Last 30 days Overall leaderboard