cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shabilass
Helper II
Helper II

Compare combo box selected items with SharePoint list column (Person or Group type)

Dear All,

I am developing PowerApps and connect the data source to SharePoint list.
In SharePoint list, there is one column name "Staff" (Person or Group type & allow multiple selection).

In PowerApps, I'm trying to do something like below:

1. User select Staff name from the combo box (I'm using edit form that connected to SharePoint list).

2. System will check if the selected name/names are in the SharePoint List (Staff column of people or group type).
3. If the selected name/names are in the SharePoint List, the "Alert" label is visible = true, else false.

Person or Group.PNG

 

Any ideas to do this?

 

Thank you in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
v-albai-msft
Community Support
Community Support

Hi @shabilass ,

Based on your description, I think you want the “Alert” label to be visible when: selecting Staff name from the combo box, as long as one of the selected name(or all selected names) is in your SP list Staff column.

I did a test in my side, below is the formula I used in my "Alert" label:

 

If(!IsEmpty(Filter(test1,DisplayName in test2.DisplayName))&& CountA(test1)>=CountA(testresult),true,false)

 

Now, I will give you a detailed steps about my formula:

1. This is my SP list called “list1” with 3 list items:

v-albai-msft_0-1610963710180.png

2. Create two collection called “test1” and “test2” using ClearCollect(), this will save the data selected from combo box and from SP Staff column separately. Also create the third collection called “testresult”, to keep the data both in “test1” and “test2”. So set the OnChange property of combo box as below to create three collections(the name of my “Staff” combo box is “DataCardValue8”):

 

ClearCollect(

    test1,

    DataCardValue8.SelectedItems.DisplayName

);

ClearCollect(

    test2,

    Ungroup(

        list1.Staff,

        "Staff"

    ).DisplayName

);

ClearCollect(

    testresult,

    Filter(

        test1,

        DisplayName in test2.DisplayName

    ).DisplayName

)​

 

Here, I add three Data Table to help you understand these three collections. The data sources of these three Data Tables are “test1”, “test2” and “testresult”:

v-albai-msft_1-1610963710185.png

3. Set the Visible property of “Alert” label using the formula I mentioned at the beginning:

 

If(

    !IsEmpty(

        Filter(

            test1,

            DisplayName in test2.DisplayName

        )

    ) && CountA(test1) >= CountA(testresult),

    true,

    false

)​

 

I will show you some results, you can compare the results with the data in the SP list mentioned in step 1:

When selecting some names that already exist in the SP list:

v-albai-msft_2-1610963710187.png

 

v-albai-msft_9-1610963828442.png

v-albai-msft_4-1610963710190.png

When one of(/more of) the selected names don't exist in the SP list("Test allen2" is exist in SP list):

v-albai-msft_8-1610963772888.png

When all selected name are not exist in SP list:

v-albai-msft_6-1610963710191.png

v-albai-msft_7-1610963710192.png

Best Regards,

Allen

View solution in original post

2 REPLIES 2
v-albai-msft
Community Support
Community Support

Hi @shabilass ,

Based on your description, I think you want the “Alert” label to be visible when: selecting Staff name from the combo box, as long as one of the selected name(or all selected names) is in your SP list Staff column.

I did a test in my side, below is the formula I used in my "Alert" label:

 

If(!IsEmpty(Filter(test1,DisplayName in test2.DisplayName))&& CountA(test1)>=CountA(testresult),true,false)

 

Now, I will give you a detailed steps about my formula:

1. This is my SP list called “list1” with 3 list items:

v-albai-msft_0-1610963710180.png

2. Create two collection called “test1” and “test2” using ClearCollect(), this will save the data selected from combo box and from SP Staff column separately. Also create the third collection called “testresult”, to keep the data both in “test1” and “test2”. So set the OnChange property of combo box as below to create three collections(the name of my “Staff” combo box is “DataCardValue8”):

 

ClearCollect(

    test1,

    DataCardValue8.SelectedItems.DisplayName

);

ClearCollect(

    test2,

    Ungroup(

        list1.Staff,

        "Staff"

    ).DisplayName

);

ClearCollect(

    testresult,

    Filter(

        test1,

        DisplayName in test2.DisplayName

    ).DisplayName

)​

 

Here, I add three Data Table to help you understand these three collections. The data sources of these three Data Tables are “test1”, “test2” and “testresult”:

v-albai-msft_1-1610963710185.png

3. Set the Visible property of “Alert” label using the formula I mentioned at the beginning:

 

If(

    !IsEmpty(

        Filter(

            test1,

            DisplayName in test2.DisplayName

        )

    ) && CountA(test1) >= CountA(testresult),

    true,

    false

)​

 

I will show you some results, you can compare the results with the data in the SP list mentioned in step 1:

When selecting some names that already exist in the SP list:

v-albai-msft_2-1610963710187.png

 

v-albai-msft_9-1610963828442.png

v-albai-msft_4-1610963710190.png

When one of(/more of) the selected names don't exist in the SP list("Test allen2" is exist in SP list):

v-albai-msft_8-1610963772888.png

When all selected name are not exist in SP list:

v-albai-msft_6-1610963710191.png

v-albai-msft_7-1610963710192.png

Best Regards,

Allen

View solution in original post

hi @v-albai-msft 

Thank you so much for helping me. It's working fine. Thanks!!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Users online (1,302)