cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Regular Visitor

Force reset of filter of collection based on dropdown selection change

Hay all, I'm pretty new at PowerApps and I'm stuck on a problem and hope someone can toss me a bone here.

 

I have a simple collection filter 

 

Filter(colLocations,ZoneLeader="Yes")

 

 based on a radio button selection to populate a ComboBox with items.

 

The Radio button selection runs an OR function in Radiobutton OnChange based on if "This OR That" has been selected in Dropdown1.

 

I would like to "re-run" this filter based on if Dropdown1 is changed again OR if Radiobutton1 selection is changed to give me a different filter of items, but so far I've only been able to reset the filter if I change dropdown1 and change the Radiobutton selection.

 

Not sure if this is possible, but I've been told pretty much Anything is possible with PowerApps, except having it fetch me a new cup of coffee. I'd very much appreciate any assistance if possible.

 

Thank you for looking!
Will

8 REPLIES 8
Super User III
Super User III

@wwallace86 

I understand that the "FetchCoffee" connector is soon going to be in beta, so hang on to your seat!

 

Can you share more about your OnChange formula where you are "Or"ing and how this fits in.

 

In general, you do not need a collection for what you are doing and your filter will be dynamic based on the conditions you want.  You stated that you are using this Collection for a Combobox, is that its sole purpose?

 

As an example, your Items property for the Combobox can easily be the following:

Filter(yourDataSource, 
   yourCriteriaBasedOnTheOtherControlsInYourApp
)

 

One thing people don't realize so much is that your Combobox in this case can act then as a datasource (or record source in this situation) and will have all the relevant information - AND be dynamic based on your source.

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes here is the formula in my Combobox OnChange.

If(Dropdown_partner.Selected.Value = "Live",
UpdateContext({Loadingvar:true});
    Switch(P2PTypeRadio.Selected.Value, "Zone2Zone", 
          UpdateContext( {allSel: Filter(colLocations, ZoneLeader = "Yes" And Live="Yes")} );
          UpdateContext( {formType: "Zone2Zone"}), "New2Zone",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Live="Yes")} );
          UpdateContext( {formType: "New2Zone"}), "Zone2Zone w/New",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Live="Yes")} );
          UpdateContext( {formType: "Zone2Zone w/New"}), "Custom",
          UpdateContext( {formType: "Custom"}), "All", 
          UpdateContext( {allSel: Filter(colLocations,New="New"||New="Normal" && Live="Yes")} );
          UpdateContext( {formType: "All"}) );
             Clear(colComboTrips);
       UpdateContext({Loadingvar:false});)
Or

If(Dropdown_partner.Selected.Value = "Dark",
UpdateContext({Loadingvar:true});
    Switch(P2PTypeRadio.Selected.Value, "Zone2Zone", 
          UpdateContext( {allSel: Filter(colLocations, ZoneLeader = "Yes" && Dark="Yes")} );
          UpdateContext( {formType: "Zone2Zone"}), "New2Zone",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Dark="Yes")} );
          UpdateContext( {formType: "New2Zone"}), "Zone2Zone w/New",
          UpdateContext( {allSel: Filter( colLocations, ZoneLeader = "Yes" || New = "New" && Dark="Yes")} );
          UpdateContext( {formType: "Zone2Zone w/New"}), "Custom",
          UpdateContext( {formType: "Custom"}), "All", 
          UpdateContext( {allSel: Filter(colLocations,New="New"||New="Normal" && Dark="Yes")} );
          UpdateContext( {formType: "All"}) );
             Clear(colComboTrips);
       UpdateContext({Loadingvar:false});)
Super User III
Super User III

@wwallace86 

So,  you are then using the allSel as the Items property of a Combobox?

 

A couple of things:

1) You really don't need collections for any of this.  You can set the Items property of your Combobox to the following:

Filter(colLocations, 
    Switch(P2PTypeRadio.Selected.Value 
        "All", (New="New"||New="Normal"),
        "New2Zone", New="New",
        "Zone2Zone w/New", New="New",
        true
    ) &&
    ((Dropdown_partner.Selected.Value = "Dark" && Dark="Yes") || (Dropdown_partner.Selected.Value = "Live" && Live="Yes"))
)

If colLocations is a collection (which I am guessing it is), then you can further get rid of that by putting your datasource directly in that formula.

The above is the same logic that you had in the formula you provided.  It can probably be factored down further, but I kept it quick.

 

2) You don't need to do anything on the OnChange of the Radio or DropDown.  Your Combobox will change dynamically based on those selections. 

 

3) You have a formType variable that you are setting to the exact same thing as your Radio selections.  You can get rid of that, and where ever you are using it, you can just set it to : P2PTypeRadio.Selected.Value

 

I'm not entirely sure where colComboTrips comes into play, but I am sure it can be factored out as well somehow. 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

@RandyHayes 

 

I can't really honestly say how I'm using allSel. I inherited this application and I can't ask the creator how it's used. I'm sort of stumbling around trying to make it do what I need it to do.

Super User III
Super User III

@wwallace86 

Well, based on what we discussed, it seemed like you were using this for the Combobox items.  Are we still on that path?  If so, what is the Items property of the Combobox?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Items property of ComboBox 

Filter(colLocations,ZoneLeader="Yes")
Super User III
Super User III

@wwallace86 

Hmmm, so the mystery is then - what is allSel used for? That seems to be the core of your OnChange action.  

Maybe I am on a tangent....you wanted the combobox list to be dynamic based on what was selected in it or the radio control.  Perhaps I am missing something here...you said "different filter of items" - did this mean in your Combobox or in something else like Gallery?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!
Super User III
Super User III

@wwallace86 

Were you able to work through your issue or do you still need help?

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too!

Helpful resources

Announcements
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (7,933)