web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Adding records from a ...
Power Apps
Answered

Adding records from a table to another table

(0) ShareShare
ReportReport
Posted on by 8

Hello,

 

I have tried googling and reading different solutions but I haven't been able to do exactly what I want.

In my example I have a table with a list of all companies and I want to select one or more of the companies to be added to a table for qualified companies. I'm imagining a gallery with a + button that adds the selected record to a gallery for selected companies.

 

Table 1 
CompanyID
A1
B2
C3
D4

 

Table 2 
Qualified companyID
C3

 

It doesn't have to be a gallery or even a data table as long as I can have a list of all of Table 1 where I can copy records to Table 2 and save the update in the source.

 

Thank you for the help!

Categories:
I have the same question (0)
  • Verified answer
    mdevaney Profile Picture
    29,991 Moderator on at

    @wleurcor 

    Put this code in the OnSelect property of the + button:

    Patch(Table2, Defaults(Table2),{ ‘Qualified Company’: Company, OriginalID: ID })


    Then use Table2 in the Items property of the other gallery.  My assumption is Table2 is your qualified companies datasource that you are saving to.

     

    You will also notice a new column called OriginalID. That’s because you can’t control the ID number in all datasources other than Excel: it’s auto-assigned.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up."

  • 365CornerDawid Profile Picture
    377 on at

    Hi,

    You can achieve such result by mixing Gallery and Collections 🙂 not sure what is your data source so my answer will be based on the collections.
    For the testing add in your app Button which and in the OnSelect property add following:
    ClearCollect(colCompanies,{CompanyName:"A",CompanyID:1},{CompanyName:"B",CompanyID:2},{CompanyName:"C",CompanyID:3},{CompanyName:"D",CompanyID:4})
    Next click the buttone - it will create collection and it will be easier to work with it.
    Add Gallery and as Items add colCompanies
    Format Gallery but it should looks more or less like 
    Annotation 2020-08-03 141343.png

    In the plus icon OnSelect add:
    Collect(colSelected,ThisItem)
    (click plus at least once)
    Add next Gallery and add colSelected and you should see new elements when you click plus icon.

    Bonus: In the Selected gallery under OnSelect of recycle bin I added so User could remove selected item:
    Remove(colSelected,ThisItem)
    Annotation 2020-08-03 1451343.png
    Hope this will help if yes please dont forget to accept the solution so other can find it easier.
    Regards
    Dawid

     

     



  • wleurcor Profile Picture
    8 on at

    Thanks for the help @365CornerDawid and @mdevaney. I use excel in OneDrive at the moment. mdevaney's solution worked for me but I also want to understand your solution to improve my Power Apps skills

     

    I looked through Collect() function and it states that it works with any data source, but for me it doesn't do anything when I press the button with Collect(Table2,ThisItem). Is it because of the data source or should I explicitly state column names? In my app the column names are identical in the two tables

     

     

  • 365CornerDawid Profile Picture
    377 on at

    Hey,

    Thanks no worries. For the intro to the collections you can start for instance with Shane's material https://www.youtube.com/watch?v=yS6mTRlmuls
    As it looks like couple things are mixed up here.
    If you want to Collect - create virtual table in the memory of Power Apps current session from your Excel data you can just do:
    Collect(colName,ExcelTableName) that will create collection of Excel data.

    ThisItem is operator used in the Gallery control basically it allows you to refer to selected element of Gallery.

    So using Collect(Table2,ThisItem) would work in Gallery and it would add new record of ThisItem to Table2.
    If Table 2 is your secondary data source second excel table then Collect might be not the best possible call. Better could be Patch function: https://www.youtube.com/watch?v=gX5q_V3U8-s

    My personal approach is that Galleries and Collections are the doors to the great Power Apps so spending time to get this two things will benefit in future 🙂

    Hope this will help.
    Feel free to ask if anything is unclear. 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 536

#2
WarrenBelz Profile Picture

WarrenBelz 426 Most Valuable Professional

#3
Haque Profile Picture

Haque 305

Last 30 days Overall leaderboard