Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Restrict Dropdown value in a gallery dropdown if the value is already selected.

(0) ShareShare
ReportReport
Posted on by 559

Hi All.

I have two columns in a gallery called "Phase" and "Work Product Process". Both are dropdown values which gets loaded from another SharePoint list. Whenever a new project is created in "Gate scope" the phase and work product for that respective project will be chosen and saved in SP list. (For eg, Phase is Governance and work product is Code and Phase is Governance and work product is CAR Report). For the created project I need to enter Gate tracker details which collects the value of Phase and work Product for the selected project from "Gate Scope" and the remaining values are entered and saved. The code to collect the Phase and Work Product for the specific project in items property is:

Phase:

Distinct(Filter(
Gate_Review_Phase,
'Project Name' = prjnamesphs.Selected.ProjectName
),Phase).Result

 

Work Product:

Distinct(Filter(
Gate_Review_Phase,
'Project Name' = prjnamesphs.Selected.ProjectName && Phase = phasedropdown.Selected.Result
),'Work Product/Process').Result

 

When the user selects Governance and Code for the first time it gets saved. For the second time when the user selects governance and code again code must not allowed to select since its is already selected.

Any help on this to implement would be greatly appreciated.

 

Thanks!

 

Categories:
  • WarrenBelz Profile Picture
    146,635 Most Valuable Professional on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @Uthhra ,

    I will be honest, we would have progressed much quicker if you had posted that highly relevant piece of code at the start. I do not fully grasp the logic in the last part of your Filter, however you now need this to be dynamic (or you will be re-collecting every time the dop-down is chosen). I will give you a start here (I will offline now for some time) - the Items of your gallery need to be something like this

    With(
     {
     wData:
     Distinct(
     GatereviewPlan_tracker
     GateID
     )
     );
     ForAll(
     wData,
     LookUp(
     Gatetracker,
     'Project Name' = 
     If(
     'Project Name' = prjnamesphs.Selected.ProjectName,
     'Project Name'
     ) && 
     GateID = Result &&
     !(GateID in colChoices.Value)
     )
     )
    );

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Sri Profile Picture
    559 on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @WarrenBelz 

    This is written On select of the button to collect the list items:

    Clear(Gate tracker);
    Collect(
    Gatetracker,
    GatereviewPlan_tracker
    );

    ClearCollect(
    colDistinct,
    Distinct(
    Gatetracker,
    GateID
    )
    );
    Clear(colFinal);
    ForAll(
    colDistinct,
    Collect(
    colFinal,
    First(
    Filter(
    Gatetracker,
    'Project Name' = If(
    'Project Name' = prjnamesphs.Selected.ProjectName,
    'Project Name'
    ) && GateID = Result
    )
    )
    )
    );

    Gallery items is:

    colFinal 

  • WarrenBelz Profile Picture
    146,635 Most Valuable Professional on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @Uthhra ,

    What are the current Items of the Gallery ?

  • Sri Profile Picture
    559 on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @WarrenBelz 

    I have mentioned in my first part of the question itself in a gallery I have two dropdown and this restriction should happen inside gallery only.

  • WarrenBelz Profile Picture
    146,635 Most Valuable Professional on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @Uthhra ,

    Sorry, but I am getting lost here - you mentioned drop-downs in your first post (which I have been focussed on and actually built a model to test it all). I really do not understand how the gallery comes into all of this - your question posted as When the user selects Governance and Code for the first time it gets saved. For the second time when the user selects governance and code again code must not allowed to select since its is already selected.

    You simply need to put the value you want to exclude into the collection, then filter for the result you want excluding that value.

  • Sri Profile Picture
    559 on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @WarrenBelz 

    Now values is getting listed in dropdown but only one value is listed(code) instead of two(code, car report). ThisItem.Result is giving an error stating Result is not recognized.

  • WarrenBelz Profile Picture
    146,635 Most Valuable Professional on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @Uthhra ,
    OnSelect of the Gallery should work, but instead of Self.Selected.Result, use ThisItem.Result

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • Sri Profile Picture
    559 on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @WarrenBelz 

    I am using a gallery to update the values in SharePoint. Because of that does it not working as expected.

  • WarrenBelz Profile Picture
    146,635 Most Valuable Professional on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @Uthhra ,

    As I noted, I tested it (again now) and it works as expected. Please look at the logic yourself - initialise Collection screen OnVisible

    ClearCollect(
     colChoices,
     {Value: Blank()}
    )

    Add any selected item selected to the Collection OnSelect of the Combo Box (small but not necessary clarification added here)

    Collect(
     colChoices,
     {Value: Self.Selected.Result}
    )

    Now filter the Combo Box Items to exclude any records in the collection

    Filter(
     Distinct(
     Filter(
     Gate_Review_Phase, 
     'Project Name' = prjnamesphs.Selected.ProjectName
     ),
     Phase
     ),
     !(Result in colChoices.Value)
    ).Result

    This code

    !(Result in colChoices.Value)

    simply means to exclude records in colChoices from the selection.

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

     

  • Sri Profile Picture
    559 on at
    Re: Restrict Dropdown value in a gallery dropdown if the value is already selected.

    @WarrenBelz ,

    The code which you posted  ! (Result in colChoices.Value) when I remove the not in the starting it is listing both the values in dropdown but only one value filtering is not happening and when I add ! the dropdown display blank values.

    Filter(
    Distinct(
    Filter(
    Gate_Review_Phase,
    'Project Name' = prjnamesphs.Selected.ProjectName
    ),
    Phase
    ),
    !(Result in colChoices.Value)
    ).Result

     

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

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,635 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,997 Most Valuable Professional

Leaderboard