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 / Add second column to c...
Power Apps
Unanswered

Add second column to collection based on values from the first column

(0) ShareShare
ReportReport
Posted on by 37

I have a list that filters names from a tableA (excel data) based on a selection made on a dropdown that has peoples state in it,

when I select items from the list (multiple selection) I have:

 

ClearCollect(CollectionA ,namelist.SelectedItems) but I would like to have a second column added to the Collection A. A column with peoples ID, this data is present on TableA (excel file).

So as I select names on namelist, I would like my collection to populate both, name and ID.

 

my file has the headers  : ID/City/Name/Phone

Categories:
I have the same question (0)
  • AmeerJab Profile Picture
    370 on at

    Hello Dear,

     

    to add new columns to your collection you can follow the below syntax 

     

    clearcollect(NewColeection, addcolumns(original collection, "New column name", and here you add the condition and expression for your new column)

     

     

  • pipkinpaula Profile Picture
    37 on at

    can you help with the condition? I tried that before but it says that I'm comparing a record to a table, here is what I tried:

     

    ClearCollect(Collection,namelist.SelectedItems);

    ClearCollect(NewCollection, AddColumns(Collection,"ID",LookUp(Collection, TableA[@Name] = Collection[@Value],TableA[@ID]))).

     

    It does not work, is says I'm comparing table to text inside the lookup part)

  • AmeerJab Profile Picture
    370 on at

    can you try 

    ClearCollect(NewCollection, AddColumns(Collection,"ID",LookUp(Collection, Name = Value,here you need to have the column from collection))).

  • AmeerJab Profile Picture
    370 on at

    in your syntax you're putting a table value in a column value 

  • pipkinpaula Profile Picture
    37 on at

    Thanks for your help, but it doesn't work, I need to use something that will compare the names saves on collection one, to my excel table and retrieve the id number to add the id number on the second column.

  • Verified answer
    AmeerJab Profile Picture
    370 on at

    Hello Dear,

     

    sorry for late response.

     

    lets take this scenario:

     

    1- you have a collection that has data from excel, and in this collection you have an Id column and a name column

    2- you have another collection that has a column names

    3- to get the id from your first column into your second collection you need this syntax

    clearCollect(Col3, Addcolumns(2ndCollection, "ID",  lookup(1stCollection, Name =  2ndCollection[@Name],id)))

     

    AmeerJab_0-1689326308669.png

     

  • pipkinpaula Profile Picture
    37 on at

    Thank you!

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 327 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard