Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Filter in gallery unchecks DropDown

(0) ShareShare
ReportReport
Posted on by 4
Hello, I have data in a gallery and I need it to change color according to the value marked in DropDowm, but when I apply a filter, all values ​​are deselected, is there any way to deal with this?
 
Attached video
  • Suggested answer
    Nandit Profile Picture
    1,563 Super User 2025 Season 1 on at
    Filter in gallery unchecks DropDown
    Hi there, I have tried replicate your use case with dummy data. 

    I have added a Patch function on the OnChange property of the dropdown within the gallery which changes the quantity value in a collection. 


    Gallery Items: 
    If(IsBlank(Dropdown2.Selected.Quantity), IceCream,  Filter(IceCream, Flavor = Dropdown2.Selected.Flavor))
    


    Dropdown within Gallery:
     

    Default: ThisItem.Quantity
    OnChange: 
    
    Patch(IceCream, ThisItem, {
    Quantity: Dropdown1.Selected.Value
    })

    Label Fill:
    Switch(ThisItem.Quantity, 100, Color.Red, 200, Color.Green, 300, Color.Blue)
     
    It seems to work for me. Do try and share the results. 
     
     
  • Michael E. Gernaey Profile Picture
    41,385 Super User 2025 Season 1 on at
    Filter in gallery unchecks DropDown
    Hi,
     
    This is due to you resetting the galleries items. Your dropdowns/combo boxes are reset, placing the Default/DefaultSelectedItem put value back in, which is 
    "nothing is selected"
     
    I haven't seen your Template fill code for changing the color so I'd have to see that, but is your Color based on whats selected in the drop down or some
    value you patched or are pulling in WHEN its selected?
     
    Meaning if you are in fact patching onchange, then your Default/DefaultSelectediTems property is wrong and needs to be updated to pull the correct value.
     
    You seem to have a couple possible things, but would need to see the code, although the video was a great source to visualize what is changing.
  • Suggested answer
    poweractivate Profile Picture
    11,078 Most Valuable Professional on at
    Filter in gallery unchecks DropDown
    Your issue could be because after changing the dropdowns that are on each record in the Gallery, making the change should cause the record to be Patched immediately with the value of the dropdown selection.

    That way, when the record is retrieved again (whether it's because it is a Filter change. opening the app again, Gallery Refresh, or any other way) the current dropdown selection and the color can automatically be applied.

    My guess is right now, that's not happening, or even if it is doing something like that in any way, it's not correct at the very least.
     
    I am guessing right now, you may have formulas that focus a lot on changing the color when the dropdown value is selected.

    Instead what you should really do is imagine as if the dropdown value already exists in the data source that way.

    If you have a test version of the data source available, or it's OK to put some test data in your data source, go ahead and even create test data where the desired value is already there, outside of Power Apps Canvas App.

    Pick a value for each test record that's not the very first one either to be sure, make like three test records or so with different values for that data.
    Be sure to create it completely outside of your Power Apps Canvas App.
     
    Next, rework your formulas. So instead of changing it when the Dropdown selection changes, it actually changes based on the data that's already coming in from your data source.

    Then it can have the correct dropdown selection and the color shown even without any user interaction at all on any dropdowns whatsoever.

    You can feel free to simply copy and paste the parts of your formulas that are working for now into the appropriate places.
    (and you can keep the original formulas where you have them just in case too, you may still find them helpful and might still even use them).
     
    The right place to put this stuff is probably under Default property of the Dropdown (for example).

    The color changing on the row might be a bit tricky but however you are doing it now, copy that over to the Color or appropriate property of the row and just try to have it work without any user interaction on the Dropdown and just have it apply based on the current value in your data source.
     
    After you get all that to work, what you also need to do is use something like the Patch Formula and place it in something like the OnChange property of the Dropdown. This is so your data for the dropdown selection can be saved instantly for that record to the data source, so that no matter what else you do after that, the color changing and the dropdown selection that you got working above, should just work after that.
     
    Specific steps on how to do this may vary depending on your particular scenario.
     
    Since you haven't provided any specific formulas (and the problem is you may have to provide quite a lot of them in this case), I leave it up to you to figure it out and won't be providing any specific formulas or specific steps for now. Hopefully the above may at least give you a good starting point.
     
    If you cannot (or really do not want to) store the value of the record's dropdown to the data source at all, then your options are much more limited and in that case, you probably can't really do what you want here. 

    You can try and use Collections which may work to some extent, but even if you do get it working with Collections somehow, all changes will be lost after the app is restarted. The easiest way is just to have this info somewhere in your data source.

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,702 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 66,015 Most Valuable Professional

Leaderboard