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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (10,251)