Search code examples
powerappspowerapps-canvaspowerapps-formula

Remove People From Drop Down If Exist in Other Fields


I have a PowerApp created using SharePoint list with multiple Person or Group type. The PowerApp has a form that allows user to select employees from M365 for a given field.

The problem is that I would like to remove person if they are already assigned/select.

This is a screenshot of the powerapp. Currently if a person is selected in Window1 they are still available to select in Window2. I would like to have that person not show as a selection option in Window2.

enter image description here

One additional catch is that the SharePoint list has Allow multiple selections enabled. Greatly appreciate any guidance/advice to solve this one.


Solution

  • Window 1: Onchange - Set(window1SelectedItem, Self.Selected.Value);

    Items - Filter(items, Value <> window2SelectedItem, Value <> window3SelectedItem, Value <> window4SelectedItem, Value <> window5SelectedItem);

    Window 2: Onchange - Set(window2SelectedItem, Self.Selected.Value);

    Items - Filter(items, Value <> window1SelectedItem, Value <> window3SelectedItem, Value <> window4SelectedItem, Value <> window5SelectedItem);

    Window 3: Onchange - Set(window3SelectedItem, Self.Selected.Value);

    Items - Filter(items, Value <> window1SelectedItem, Value <> window2SelectedItem, Value <> window4SelectedItem, Value <> window5SelectedItem);

    Window 4: Onchange - Set(window4SelectedItem, Self.Selected.Value);

    Items - Filter(items, Value <> window1SelectedItem, Value <> window2SelectedItem, Value <> window3SelectedItem, Value <> window5SelectedItem);

    Window 5: Onchange - Set(window5SelectedItem, Self.Selected.Value); Items - Filter(items, Value <> window1SelectedItem, Value <> window2SelectedItem, Value <> window3SelectedItem, Value <> window4SelectedItem);

    if this answer is helpful feel free to accept it as a correct answer.