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 / Restrict Dropdown valu...
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:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    Hi @Uthhra ,

    This can be a bit tricky to not interfere with the user experience, but one way would be to set a Variable when you save the Form

    UpdateContext({varSaved: true})

    then on the DisplayMode of both drop-downs

    If(
     varSaved,
     DisplayMode.View,
     Parent.DisplayMode
    )

    also at screen OnVisible or anywhere else you need to unlock them

    UpdateContext({varSaved: false})

     

    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

    Hi @WarrenBelz ,

    But by setting a variable how can I restrict the user by not selecting the previous selected value.

     

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Uthhra ,

    Sorry, I do not understand the question - I am simply making the drop-downs read-only after the form is saved.

  • Sri Profile Picture
    559 on at

    @WarrenBelz,

    Once the user selects the dropdown value, the selected dropdown value must be removed and rest of the values only should be displayed.

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Uthhra ,

    Maybe Set a Variable OnSelect 

    UpdateContext({varSelected: Self.Selected.Result})

    Your would also need Screen OnVisible

    UpdateContext({varSelected: Blank()})

    and then the Items

    Filter(
     Distinct(
     Filter(
     Gate_Review_Phase, 
     'Project Name' = prjnamesphs.Selected.ProjectName
     ),
     Phase
     ),
     Result <> varSelected
    ).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

    @WarrenBelz 

    If I give it in above way the selected value goes blank. (For eg if the dropdown values are code and car report, and the user selects Car report and the second time when selecting car report should not be displayed in dropdown only  code must be listed).

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Uthhra ,

    I tested here and when you re-select, it changes the variable (so you get it back, although it is not blank). I have tested this and it works - OnSelect of the Combo Box

    Collect(
     colChoices,
     Self.Selected.Result
    )

    Items of the Combo Box

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

    Screen OnVisible

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

     

    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

    @WarrenBelz 

    I tried giving the above code and my dropdown is not listing any values and it is blank.

  • WarrenBelz Profile Picture
    153,026 Most Valuable Professional on at

    @Uthhra ,

    As I noted, I tested it and it works, so there is something missing on your end. As a temporary measure, put a button on the screen (to imitate navigating to it) with

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

    Next do you get items in your drop-down with this

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

    If so, the combination I posted should work.

     

    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

    @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

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 796 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard