cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
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
Microsoft
Microsoft

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
Microsoft
Microsoft

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
News & Announcements

Community Blog

Stay up tp date on the latest blogs and activities in the community News & Announcements.

Power Apps Community Call

Power Apps Community Call- January

Mark your calendars and join us for the next Power Apps Community Call on January 20th, 8a PST

PP Bootcamp Carousel

Global Power Platform Bootcamp

Dive into the Power Platform stack with hands-on sessions and labs, virtually delivered to you by experts and community leaders.

secondImage

Power Platform Community Conference On Demand

Watch Nick Doelman's session from the 2020 Power Platform Community Conference on demand!

Top Solution Authors
Top Kudoed Authors
Users online (9,171)