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 / Joining 2 database in ...
Power Apps
Unanswered

Joining 2 database in 1 datatable

(1) ShareShare
ReportReport
Posted on by 55

Please show me how to arrange the data table with two databases, because the first table appeared on the upper. but I need to combine and sort them according to the transaction date. 

and also in the second database, the value didn't display on the datatable; it looked like this.

 

cha143_0-1719900862607.png

 

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

    Hi @cha143,

    To join 2 tables, use the Table() function. Any matching columns will be merged into a single column, and unique columns will be appended to the table. For example, add a button that collects to tables:

    ClearCollect(tbl1, 
    {ID: 1, Title: "A", Value: 1000},
    {ID: 2, Title: "B", Value: 2000},
    {ID: 3, Title: "C", Value: 3000},
    {ID: 4, Title: "D", Value: 4000});
    ClearCollect(tbl2, 
    {ID: 5, Title: "E", TextValue: "AAA"},
    {ID: 6, Title: "F", TextValue: "BBB"},
    {ID: 7, Title: "G", TextValue: "CCC"},
    {ID: 8, Title: "H", TextValue: "DDD"})

    Then, add a table control to display the merged tables and set its Items property to:

    Table(tbl1, tbl2)

    You should get the following:

    royg_0-1719902772612.png

    Hope this helps

     

  • cha143 Profile Picture
    55 on at

    my table are from sql and SP i think i didnt declared the value of the table

  • royg Profile Picture
    on at

    No need to declare, that was purely for demo purposes. 

    Try joining both your table objects using the Table() function and share the results.

  • anandm08 Profile Picture
    1,936 Super User 2024 Season 2 on at

    hi @cha143 ,

    Retrieve Data from Both Databases

    Assume you have two databases, DB1 and DB2. First, retrieve the data and store it in collections.

     

    // Retrieve data from the first database
    ClearCollect(CollectedData1, DB1);
    
    // Retrieve data from the second database
    ClearCollect(CollectedData2, DB2);

     

    Combine Data

    Combine the data from both collections into a single collection.

     

    // Combine data from both collections
    ClearCollect(CombinedData, CollectedData1, CollectedData2);

     

    Sort Combined Data

    Sort the combined data collection by the transaction date.

     

    // Sort the combined data by transaction date
    ClearCollect(SortedData, SortByColumns(CombinedData, "TransactionDate", Ascending));

     

    Display in Data Table

    Bind the sorted collection to the data table.

    1. Add a Data Table control to your PowerApps screen.
    2. Set the Items property of the Data Table to SortedData.

     

    SortedData​

     

    This approach ensures that data from both databases is combined, sorted by the transaction date, and displayed correctly in the data table. If there are specific issues with the second database not displaying values, ensure to debug by checking field names, data types, and connections.

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 401 Most Valuable Professional

#2
11manish Profile Picture

11manish 201 Super User 2026 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 128 Super User 2026 Season 2

Last 30 days Overall leaderboard