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 / AddColumns to Collecti...
Power Apps
Answered

AddColumns to Collection only showing first value

(0) ShareShare
ReportReport
Posted on by 11

Hello. I'm attempting to add a column from one Sharepoint List to a collection "joined" by a 'Case ID' to be used in searching. The problem is the new collection is only pulling the first item in the column rather than all associated items based on the Case ID. If there is a better way to do this please let me know as I'm stumped. Thank you

 

 

ClearCollect(viewCollection, (AddColumns('Basic Case Information',"Name",LookUp('Name Information', 'Case ID'='Basic Case Information'[@'Case ID'],'Name'))));

 

 

Example:
Basic Case Information

Case ID: 1234

Case ID: 1235

 

Name Information

Case ID: 1234 / Name: John, Joe, Jenny

Case ID: 1235 / Name: Shaun, Sam, Sarah 

 

viewCollection:
Case ID: 1234 / Name: John

Case ID: 1235 / Name: Shaun

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @ColoradoMike 

    Can you describe further what you mean when you show the Name value with three different names.

    Or, more importantly, in your SharePoint List (Name Information) what kind of column is Name?  Is it a Text column?

  • ColoradoMike Profile Picture
    11 on at

    The Name Column is a text column. So in the Name Information list I have a text column for Case ID and a text column for Name. There are multiple records associated with each Case ID with different names. But the AddColumns/Lookup combination is only pulling the first record associated with the Case ID: 1234/John and 1235/Shaun (bolded below), rather than all names associated. 

     

    Name Information List

    Case IDName
    1234John
    1234Joe
    1234Jenny
    1235Shaun
    1235Sam
    1235Sarah

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @ColoradoMike 

    So then, if you want to get all the names in a coma separated format, then you can use the following formula:

    ClearCollect(viewCollection, 
     AddColumns('Basic Case Information',
     "Name", Concat(
     Filter(
     AddColumns('Name Information', "caseID", 'Case ID'), 
     caseID = 'Case ID'
     ),
     Name & ","
     )
     )
    )

     

    This will get all the records from the 'Name Information' List that matches the caseID.  Notice that we add a column to the datasource with a duplicated Case ID.  Although there are several "workarounds" to doing this, some testing lately has found inaccurate results, so I didn't mention them here but simply gave the tried-and-true method - which is to add a column and use that to avoid ambiguity.   This is all then used in a Concat function which will iterate on the Name columns and separate with comas.

     

    See how that works for you.

     

  • ColoradoMike Profile Picture
    11 on at

    Thanks, @RandyHayes .

    Progress! But now it appears to be adding all names to each record in viewCollections rather than separating them out. I tried tinkering a bit, but no luck. 

    For clarity, when I view the Name column in viewCollections it shows John,Joe,Jenny,Shaun,Sam,Sarah in each 1234 and 1235 records. 

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @ColoradoMike 

    Ooops...my bad, I meant to do a rename columns function not the add columns.

    Here is the revised:

    ClearCollect(viewCollection, 
     AddColumns('Basic Case Information',
     "Name", Concat(
     Filter(
     RenameColumns('Name Information', "Case ID", "caseID"), 
     caseID = 'Case ID'
     ),
     Name & ","
     )
     )
    )

     

    Sorry about that...was moving too quick.

  • ColoradoMike Profile Picture
    11 on at

    That did it! Thank you very much for your time

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @ColoradoMike 

    Any time!  And welcome to the forum.  Feel free to post any other issues you might have.

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 765 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 272

Last 30 days Overall leaderboard