cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Hide Previously Selected Dropdown Results

I have multiple dropdown controls (drpCont1 and drpCont2, etc) on a screen that all get their values from the same SharePoint list. For the sake of this example, we will name the list 'HelperList'. I need to return the 'Description' column and it that needs to be filtered by another column named 'Degree'. The following filter is returning the filtered results but drpCont2 is still showing the previously selected item from drpCont1. I would like to hide this value from the results and subsequently do the same for the other items. 

 

Filter(Distinct(Sort(HelperList,Degree.Value="MPH" & Description,Ascending),Description),drpCont2<>drpCont1)

 

Basically, I just need for each dropdown on the screen to be unique. Is this possible?

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Helper I
Helper I

Re: Hide Previously Selected Dropdown Results

After multiple attempts trying to setup the collection, I punted and with the suggestion from Shane Young I ended up using a filter for the OnSelect properties of the dropdown controls. I then added a label using a visible variable to show a warning text if there was a duplicate selection and had the control reset. I also disable the submit button if one of the variables were set to true. I would have preferred having the content filtered by this will do what I need it to do.

 

If(drpCont1.SelectedText.Value = drpCont2.SelectedText.Value
Or drpCont1.SelectedText.Value = drpCont3.SelectedText.Value
Or drpCont1.SelectedText.Value = drpCont4.SelectedText.Value
Or drpCont1.SelectedText.Value = drpCont5.SelectedText.Value, UpdateContext({varShowDup1:true}),Reset(drpCont1))

View solution in original post

7 REPLIES 7
Highlighted
Super User
Super User

Re: Hide Previously Selected Dropdown Results

@BigE 

Put this code in the OnVisible property of your screen.  It will create a collection with all of the values that could possibly be loaded in the dropdown.

 

ClearCollect(
    colDropdownOptions
    Distinct(
        Sort(HelperList,Degree.Value="MPH" & Description, Ascending),
        Description
    )
);
ClearCollect(
    colDropdownOptionsUnique,
    colDropdownOptions
);

 

Then use this code in the OnChange property of each dropdown.  It will filter the collection only on options that were not yet chosen.

 

ClearCollect(
    colDropdownOptionsUnique
    Filter(colDropdownOptions,
        Description <> drpCont1.Selected.Value
        And Description <> drpCont2.Selected.Value
        And Description <> drpCont3.Selected.Value
        And Description <> drpCont4.Selected.Value
    )
);

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Helper I
Helper I

Re: Hide Previously Selected Dropdown Results

@mdevaney this looks great however, I have an error stating that colDropdownOptions isn't a valid name. Does this need to be declared somewhere else?

Highlighted
Super User
Super User

Re: Hide Previously Selected Dropdown Results

@BigE 

I made a change to my first section of code above in the 2nd CLEARCOLLECT function.

 

ClearCollect(
    colDropdownOptionsUnique,
    colDropdownOptions
);

 

If this doesn't fix the error, can you please show a screenshot of the error message?

 

---
Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

Highlighted
Helper I
Helper I

Re: Hide Previously Selected Dropdown Results

@mdevaney it's still giving me the error. Should there be something after colDropdownOptions like a "," or "("

 

Screen Shot 2020-03-17 at 4.28.58 PM.png

Highlighted
Super User
Super User

Re: Hide Previously Selected Dropdown Results

@BigE 

Looks like I had incorrect brackets in a few places.  Sorry, that's a side product of me writing this from memory without a code checker.  Let's try again...

 

---

 

Put this code in the OnVisible property of your screen.  It will create a collection with all of the values that could possibly be loaded in the dropdown.

 

ClearCollect(
    colDropdownOptions
    Distinct(
        Sort(HelperList,Degree.Value="MPH" & Description, Ascending),
        Description
    )
);
ClearCollect(
    colDropdownOptionsUnique,
    colDropdownOptions
);

 

Then use this code in the OnChange property of each dropdown.  It will filter the collection only on options that were not yet chosen.

 

ClearCollect(
    colDropdownOptionsUnique
    Filter(colDropdownOptions,
        Description <> drpCont1.Selected.Value
        And Description <> drpCont2.Selected.Value
        And Description <> drpCont3.Selected.Value
        And Description <> drpCont4.Selected.Value
    )
);

 

Highlighted
Helper I
Helper I

Re: Hide Previously Selected Dropdown Results

@mdevaney it needed a "," after colDropdownOptions in the first group and after colDropdownOptionsUnique in the second group. The code checked out ok but it still would not load filter out that list. Should the item properties for each dropdown be something specific? Originally they were set to Filter(HelperList,Degree.Value = "MPH"). Could this be causing an issue?

Highlighted
Helper I
Helper I

Re: Hide Previously Selected Dropdown Results

After multiple attempts trying to setup the collection, I punted and with the suggestion from Shane Young I ended up using a filter for the OnSelect properties of the dropdown controls. I then added a label using a visible variable to show a warning text if there was a duplicate selection and had the control reset. I also disable the submit button if one of the variables were set to true. I would have preferred having the content filtered by this will do what I need it to do.

 

If(drpCont1.SelectedText.Value = drpCont2.SelectedText.Value
Or drpCont1.SelectedText.Value = drpCont3.SelectedText.Value
Or drpCont1.SelectedText.Value = drpCont4.SelectedText.Value
Or drpCont1.SelectedText.Value = drpCont5.SelectedText.Value, UpdateContext({varShowDup1:true}),Reset(drpCont1))

View solution in original post

Helpful resources

Announcements
secondImage

Demo-Extravaganza 2020

Check out these cool Power Apps & vote on your favorite!

secondImage

Robotic Process Automation

Let's talk about the solution provided by Microsoft for Robotic Process Automation (RPA)

secondImage

Community Highlights

Check out whats happening in Power Apps

secondImage

Community User Group Member Badges

FIll out a quick form to claim your community user group member badge today!

Top Solution Authors
Top Kudoed Authors
Users online (8,476)