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 / show unique value in c...
Power Apps
Answered

show unique value in comboboxes

(0) ShareShare
ReportReport
Posted on by 304

Hi,

my app contains multiple comboboxes linked to a sharepoint list, for example "monitor 1" and "monitor 2". The comboboxes only show items linked to a specific user from a people picker.

My problem now is, that if a user has only one monitor, both comboboxes show the same one. Is it possible to somehow check if one item is already selected in the first combobox and if yes don't show anything in the second one? And also for manually selecting, like if a user selects item 1 in combobox 1, they can't select item 1 in combobox 2?

 

This is my current code for default selected items in both "monitor" comboboxes:

 

If(
 !IsBlank(UserField.SelectedItems);
 Distinct(
 Filter(
 Monitors;
 Status.Value = "Handed out" &&
 Len(User.Email) > 0 &&
 User.Email = UserField.Selected.Email
 );
 'Asset ID'
 )
)

 

 

Categories:
I have the same question (0)
  • Verified answer
    anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @LisKr ,

    Items for First Combobox:

    Distinct(
     Filter(
     Monitors;
     Status.Value = "Handed out" &&
     Len(User.Email) > 0 &&
     User.Email = UserField.Selected.Email
     );
     'Asset ID'
    )

     

    Items for Second Combobox:

    If(
     !IsBlank(FirstComboBox.Selected),
     Filter(
     Distinct(
     Filter(
     Monitors;
     Status.Value = "Handed out" &&
     Len(User.Email) > 0 &&
     User.Email = UserField.Selected.Email
     );
     'Asset ID'
     ),
     'Asset ID' <> FirstComboBox.Selected.'Asset ID'
     ),
     Distinct(
     Filter(
     Monitors;
     Status.Value = "Handed out" &&
     Len(User.Email) > 0 &&
     User.Email = UserField.Selected.Email
     );
     'Asset ID'
     )
    )

     

     

    OnChange for First Combobox:

    Reset(SecondComboBox)

     

     

    OnChange for Second Combobox:

    If(
     SecondComboBox.Selected.'Asset ID' = FirstComboBox.Selected.'Asset ID',
     Notify("This item is already selected in the first combobox.", NotificationType.Error);
     Reset(SecondComboBox)
    )

     

  • LisKr Profile Picture
    304 on at

    Thank you for your reply @anandm08 

     

    I get errors when trying your code for the items property of the second combobox. Firstly, it doesn't recognize Asset ID in Combobox.Selected.'Asset ID'. Asset ID is my column name in my list and it seems like I can't refer to it at this point. So I tried using Combobox.Selected.Value, it should do the same, right?

     

    Secondly, I get an error at

    'Asset ID' <> FirstComboBox.Selected.'Asset ID'

     


    It says "incompatible type for comparison: Record, Record". But record is the same data type, so why is that happening?

  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at
    1. Referencing Column Values in Combobox Selected Item: Yes, if 'Asset ID' is the column name in your list, then you should reference it as Combobox.Selected.Value. The 'Asset ID' is usually referenced directly as Combobox.Selected.Value, assuming Combobox represents a dropdown control bound to the SharePoint list. So you can replace 'Asset ID' with Combobox.Selected.Value in your formula.

    2. Error with Comparing Records: The error "incompatible type for comparison: Record, Record" typically occurs when you try to compare two entire records instead of their specific fields. Since we're comparing the 'Asset ID' field of the records, we need to directly compare the values of those fields, not the records themselves.

    Here's how you can adjust the formula:

     

    Filter(
     Distinct(
     Filter(
     Monitors;
     Status.Value = "Handed out" &&
     Len(User.Email) > 0 &&
     User.Email = UserField.Selected.Email
     );
     'Asset ID'
     );
     Value <> FirstComboBox.Selected.Value
    )

     

  • LisKr Profile Picture
    304 on at

    Thanks for your detailed explanation, that sounds very logical.

    Unfortunately, the new formula throws no error, but it also doesn't do anything. There's still the same default items shown in both comboboxes.

  • LisKr Profile Picture
    304 on at

    It seems like I needed to put that code into default selected items, too. Now it works.

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard