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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Showing all items insi...
Power Apps
Unanswered

Showing all items inside a combobox that are related to the selected items on another combo box will only show the ones related to the last select item

(0) ShareShare
ReportReport
Posted on by 1,811 Super User 2024 Season 1

I have this problem; Showing all items inside a combobox that are related to the selected items on another combo box will only show the ones related to the last select item.

 

I have 2 combo boxes, Media and Networks inside the Booking Calendar Form>> where a network can be linked to one media and a media can be linked to multiple networks

 

now i have 2 combo boxes inside my form:-

 

1) Media combo box

-Items:-

With(
 {
 _Start: 
 Filter(
 Media,
 StartsWith(
 Title,
 Self.SearchText
 )
 )
 },
 Sort(
 
 _Start,
 Title
 
 )
)

 

DefaultSelectItems:- 

Filter(Media,ID in Filter(BookingCalendarMedia,'Booking Calendar ID'=ThisItem.ID).'Medium ID')

 

2) Network combobox

-Items:-

With(
 {
 _Start: 
 Filter(
 Networks,
 StartsWith(
 Title,
 Self.SearchText
 ) And 'Medium ID' in ShowColumns(BookingCalendarMediaComboBox.SelectedItems,"ID")
 
 
 )
 },
 Sort(
 
 _Start,
 Title
 
 )
)

 

DefaultSelectItems:- 

Filter(Networks,ID in Filter(BookingCalendarNetwork,'Booking Calendar ID'=ThisItem.ID).'Network ID')

 

now when i select the first media item >> the related network will be shown correctly >> but when i select the second media, only network related to the newly selected media will be shown, while the previous networks will be unselected.. any advice how to fix this?

Categories:
I have the same question (0)
  • M_Ali_SZ365 Profile Picture
    1,110 on at

    HI @johnjohnPter ,

    Modify Network Combobox Items Property: You need to change the filter condition in the Network combobox so that it shows networks related to all selected media items, not just the last one. Update the 'Items' property of the Network combobox to something like this:

    With(
     {
     _Start: 
     Filter(
     Networks,
     StartsWith(
     Title,
     Self.SearchText
     ) And 'Medium ID' in ShowColumns(BookingCalendarMediaComboBox.SelectedItems,"ID")
     )
     },
     Sort(
     _Start,
     Title
     )
    )

    Ensure Proper Relationship Mapping: Verify that the relationship between Media and Networks is correctly mapped in your data source. Each network should be properly linked to its corresponding media.

    Test with Multiple Selections: After updating the filter logic, test the form by selecting multiple media items to ensure that the networks shown in the combobox include all networks related to each selected media item.

    Debugging: If the issue persists, use the Power Apps debugging tools to check the values being passed in the filter and identify where the logic might be failing.

    By modifying the filter logic, the Network combobox should display networks related to all selected media items, not just the last one. This ensures a more dynamic and responsive user experience in your Power Apps form.

    If this solution resolves your issue, please consider marking it as accepted. ✅

    Warm regards,
    Muhammad Ali

  • Hassan_SZ_365 Profile Picture
    542 on at

    Hi @johnjohnPter ,

    To ensure that the Network combobox shows all items related to all selected items in the Media combobox, you will need to adjust the filtering logic to account for multiple selections. Here's a brief outline of how you can modify the 'Items' property of the Network combobox to achieve this:

    1. Allow Multiple Selections: Make sure your Network combobox is set to allow multiple selections if it's not already.

    2. Modify Network Items Formula: Change the 'Items' property of the Network combobox to include all networks related to any selected media. You can use the Collect function with a ForAll loop over the selected media items to gather all related networks.

    Here's a simplified version of the logic you might use for the Network combobox 'Items' property:

     

    With(
     {
     _SelectedMediaIDs: BookingCalendarMediaComboBox.SelectedItems.ID
     },
     SortByColumns(
     Filter(
     Networks,
     'Medium ID' in _SelectedMediaIDs
     ),
     "Title"
     )
    )

     

    This code snippet creates a collection of selected media IDs and filters the Networks to show only those related to any of the selected media.

    1. Maintain Selections: If you want to maintain the network selections even when changing the media selections, you'll need to manage this through additional logic that stores the previously selected networks and re-applies them as selections change.

    Make sure that 'Medium ID' is the correct column name in the Networks entity that references the ID in the Media entity. Adjust the placeholder BookingCalendarMediaComboBox to the actual name of your Media combobox control.

    Best Regards,
    Hassan Raza

  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at

    @M_Ali_SZ365 but is not the formula you provided exactly the same as my formula inside the network items property?

  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at

    @Hassan_SZ_365 but how i can still search the combobx as mentioned in my code?

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @johnjohnPter ,

    You're right, the formula I suggested for the Network combobox is indeed similar to the one you're currently using. For resolving the issue where only networks related to the last selected media item are shown, let's refine the approach:

    Adjust the Filter Condition in the Network Combobox: To show networks related to all selected media items, you need to modify the filter condition. The goal is to include networks that are linked to any of the selected media items, not just the last one.

    Use Collection to Store Selected Media IDs: When a media item is selected, add its ID to a collection. This collection will keep track of all selected media items.

    Update Network Combobox Filter: Modify the 'Items' property of the Network combobox to filter networks based on all media IDs in your collection. This way, the combobox will display networks related to all selected media items.

    Example:

    With(
    {
    _Start:
    Filter(
    Networks,
    StartsWith(
    Title,
    Self.SearchText
    ) And 'Medium ID' in YourMediaCollection
    )
    },
    Sort(
    _Start,
    Title
    )
    )

    Replace YourMediaCollection with the name of the collection that stores the selected media IDs.

    Update the Logic for Media Selection: Ensure that your logic for selecting media items properly adds/removes items from this collection.

    Testing: After implementing these changes, test your app to ensure that the Network combobox reflects networks related to all selected media items.

    This approach should address the issue and allow the Network combobox to dynamically display networks associated with all selected media items.

    If this solution resolves your issue, please consider marking it as accepted. ✅

    Warm regards,
    Muhammad Ali

     

     

  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at

    @M_Ali_SZ365 your reply was very fast, not sure how you had the time to type all this text,, are you using any AI tools to post your replies? Thanks

    Espically in your first reply, you just posted the same formula i posted in, which is something that AI tools usually do 🙂 

  • johnjohnPter Profile Picture
    1,811 Super User 2024 Season 1 on at

    @M_Ali_SZ365 in all the cases your formula did not work

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @johnjohnPter ,

    Whenever a media item is selected, add it to a collection that holds all selected media IDs.

    // This should be triggered whenever a media item is selected or deselected
    ClearCollect(colSelectedMedia, MediaComboBox.SelectedItems)

    Update the Items property of the Network combobox to filter based on the entire collection of selected media.

    With(
     {
     _FilteredNetworks: 
     Filter(
     Networks,
     'Medium ID' in colSelectedMedia.ID
     )
     },
     Sort(_FilteredNetworks, Title)
    )

    Make sure that you replace MediaComboBox.SelectedItems with the actual name of your media selection control,

    If this solution resolves your issue, please consider marking it as accepted. ✅

    Warm regards,
    Muhammad Ali

    and colSelectedMedia.ID matches the column name in your collection that stores the media IDs.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 765 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 272

Last 30 days Overall leaderboard