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 / Find a value in a coll...
Power Apps
Answered

Find a value in a collection if another collection column has data

(0) ShareShare
ReportReport
Posted on by 45

Hi, I have 2 collections and I want to validate that the columns in one collection have values on the other one, the collections look like this, any help is appreciate it

 

Collection One

TittleDescription
Area 1Training 1
Area 1Training 2
Area 1Training 3
Area 1Training 4
Area 1Training 5

 

Collection 2

 

Employee #Training Name
1234Training 1
1234Training 5
5555Training 1
5555Training 2
5555Training 3
9999Training 1
9999Training 2
9999Training 3
9999Training 4

 

Resulting Collection

Employee #Training 1Training 2Training 3Training 4Training 5
1234YesNoNoNoYes
5555YesYesYesNoNo
9999YesYesYesYesNo

 

Categories:
I have the same question (0)
  • madlad Profile Picture
    2,637 Moderator on at

    You could do something like:

     

    ClearCollect(
     Results, 
     ForAll(
     GroupBy(Collection 2, "Employee #", "IDGroup") As C2, 
     {
     'Employee #': 
     C2.'Employee #', 
     Checking:
     ForAll(
     Collection1 As C1, 
     {
     'Description': 
     C1.'Description', 
     Done: 
     If(
     C1.'Description' in C2.IDGroup.'Training Name', 
     true, 
     false
     )
     }
     )
     }
     )
    )

     

    It's not exactly, like the picture, but for all intents and purposes you should be able to use it the same way - every Employee will have X amount of training completion values with either true or false associated, depending on whether they're in collection 2 or not.

     

    Hope this helps!

  • RomeroCastroK Profile Picture
    45 on at

    Thanks for the help

     

    I get the following error on the IF line

     

    If(
    C1.Description in C2.GroupByUsersDisplayName.'Training Course',
    true,
    false
    )

    "Can't convert this data type. Powerapps cant convert this Text to a Record

     

    The 'Training Course' column is a record containing "Name" and "ID"

     

    how can i compare to Name only?

     

    regards

     

     

     

  • madlad Profile Picture
    2,637 Moderator on at

    Are you able to use C2.GroupByUsersDisplayName.'Training Course'.Name? If not we will have to try remove ID earlier in the code. 

  • RomeroCastroK Profile Picture
    45 on at

    Tried that but it doesnt work

  • madlad Profile Picture
    2,637 Moderator on at

    Unfortunate; We will have to change the filter a bit. 

    Maybe try something like:

     

     

    ClearCollect(
     Results, 
     ForAll(
     GroupBy(
     ForAll(
     Collection 2,
     {ID: ThisRecord.ID, Name: ThisRecord.'Training Course'.Name}
     ), 
     "Employee #", 
     "GroupByUsersDisplayName"
     ) As C2, 
     {
     'Employee #': 
     C2.'Employee #', 
     Checking:
     ForAll(
     Collection1 As C1, 
     {
     'Description': 
     C1.'Description', 
     Done: 
     If(
     C1.'Description' in C2.GroupByUsersDisplayName.Name, 
     true, 
     false
     )
     }
     )
     }
     )
    )

     

    As this will make replace 'Training Course' with just the name

  • RomeroCastroK Profile Picture
    45 on at

    this is what I have but it gives me errors, I had to group the and add columns to get the user DisplayName because the column a "Group Person" column in Sharepoint

     

    ClearCollect(
    Results,
    ForAll(
    ForAll(
    DatabyArea,
    {ID: ThisRecord.ID, Name: ThisRecord.'Training Course'.Value}
    );
    GroupBy(AddColumns(DatabyArea,"UserDisplayName", 'Employee Name'.DisplayName), "UserDisplayName", "GroupByUsersDisplayName") As C2,
    {
    'UserDisplayName':
    C2.'UserDisplayName',
    Checking:
    ForAll(
    DataTraArea As C1,
    {
    Description:
    C1.Description,
    Done:
    If(
    C1.Description in C2.GroupByUsersDisplayName.Name,
    true,
    false
    )
    }
    )
    }
    )
    )

  • madlad Profile Picture
    2,637 Moderator on at

    What's the error it's giving you, and where is it hightlighted over?

  • RomeroCastroK Profile Picture
    45 on at

    the red part, says Function Group By has invalid argument and Employee Name isn't recognized

     

    ClearCollect(
       Results,
       ForAll(
           GroupBy(
                   ForAll(
                   DatabyArea,
                   {ID: ThisRecord.ID, Name: ThisRecord.'Training Course'.Value}
            ),
            'Employee Name'.DisplayName,"GroupByUsersDisplayName") As C2,
           {
             Name:
             C2.Name,
             Checking:
             ForAll(
                  DataTraArea As C1,
                  {
                      Description:
                      C1.Description,
                      Done:
                      If(
                        C1.Description in C2.GroupByUsersDisplayName.Name,
                        true,
                        false
                      )
                  }
               )
           }
        )
    )

  • madlad Profile Picture
    2,637 Moderator on at

    Ahh I see. Try replacing the highlighted with:

     

    GroupBy(
     AddColumns(
     DatabyArea,
     "Name",
     ThisRecord.'Training Course'.Value, 
     ),
     'Employee Name'.DisplayName, 
     "GroupByUsersDisplayName"
    ) As C2

     

    You'll notice I changed the ForAll to AddColumns. I did this mainly because it maintains the original structure of the table, instead of my old forall, which was completely making a new table. This likely would have been the better option to begin with to be honest i should have thought of it sooner.

     

    Hope this helps!

  • RomeroCastroK Profile Picture
    45 on at

    thanks, but Im still getting errors on the red part

     

    ClearCollect(
         Results,
            ForAll(
                GroupBy(
                    AddColumns(
                        DatabyArea,
                       "Name",
                       ThisRecord.'Training Course'.Value
                     ),
                    'Employee Name'.DisplayName,
                     "GroupByUsersDisplayName"

                 ) As C2
                {
                Name:
                C2.Name,
                Checking:
                ForAll(
                       DataTraArea As C1,
                       {
                       Description:
                       C1.Description,
                       Done:
                       If(
                           C1.Description in C2.GroupByUsersDisplayName.Name,
                           true,
                           false
                        )
                     }
                 )
               }
         )
    )

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 320 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard