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 / Create Collection with...
Power Apps
Answered

Create Collection with columns from 2 data sources

(0) ShareShare
ReportReport
Posted on by 5,836 Moderator

Wow, there are a LOT of possible solutions for this.   I haven't found the right one yet as most are either at one end or the other of what I need to do.

 

I need to create a collection of data that pulls all the detail information for a specific date from one collection and then add the master data to each record.

 

DataSource1 - MasterData:

 

ProjectName

ProjectType

CourseType

ID (Key field)

 

DataSource2 - Detail:

 

Title (Text field, This is a person)

Role

WeekEnding

Hours

MasterID (Key field)

 

I need to create a filtered collection of data from DataSource2 for a specific date and for each record that is found, add the corresponding data (ProjectName, ProjectType & CourseType) from DataSource1 using the ID-MasterID match.

 

The result:

 

Collection:

 

ProjectName

ProjectType

CourseType

Title

Role

WeekEnding

Hours

 

 

I found solutions for adding all columns and adding a single column but not for adding specific multiple columns.

 

Any help will be greatly appreciated.

 

Categories:
I have the same question (0)
  • BCLS776 Profile Picture
    8,994 Moderator on at

    How about?:

    ClearCollect(colCollection,Blank());
    ForAll(DataSource2 As ItemTable,
     Collect(colCollection,
     {
     ProjectName: LookUp(DataSource1, ID = ItemTable.MasterID,ProjectName),
     ProjectType: LookUp(DataSource1, ID = ItemTable.MasterID,ProjectType),
     CourseType: LookUp(DataSource1, ID = ItemTable.MasterID,CourseType), 
     Title: ItemTable.Title,
     Role: ItemTable.Role,
     WeekEnding: ItemTable.WeekEnding,
     Hours: ItemTable.Hours
     }
     )
    );
  • Verified answer
    Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @JR-BejeweledOne 

     

    didnt test it, should be like :

     

     

    Clear(colDetailWithMasterData);
    ForAll( Filter(Detail, yourColumn = yourdate) As ThisDetail,
        With({tempMasterData: LookUp(MasterData, ID = ThisDetail.MasterID )},
            Collect(colDetailWithMasterData,
            {
            'ProjectName': tempMasterData.ProjectName,
            .... etc for data taken from masterdata
            'Title': ThisDetail.Title,
            .... etc for data taken from Detail
            }
            )
        )
    )

  • Al_10 Profile Picture
    1,691 Super User 2024 Season 1 on at

    @JR-BejeweledOne 

    oops, you have got the answer already

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    This is great.    After thinking about it, I am wondering if this formula could be adapted to provide the same capability (displaying the related information) without creating a collection to do it?

  • BCLS776 Profile Picture
    8,994 Moderator on at

    With this kind of ForAll structure, you could Patch back to your DataSource2 and add columns to it.

     

    Or, a ForAll can directly return a table, but it doesn't work to add columns that way.

     

    Maybe an AddColumns with Lookup inside is what you are after?

     

    I'm curious, why avoid making the collection?

     

     

  • JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    It's not necessary to avoid the collection, it might make it a little easier on the updating side of things.   It was more curiosity than anything else as I work through the best way to keep the overhead down.

  • Verified answer
    JR-BejeweledOne Profile Picture
    5,836 Moderator on at

    I found a way to do what I was attempting.   I really didn't need the collection at all.  The only value it was providing was displaying the merged information from the two data sources.   It was only used for seeing what had been added today and providing a vehicle to edit the information.

     

    Here is the Video I found:  https://www.youtube.com/watch?v=U-WN4OFZ1kw

     

    And this ended up being my formula.  It works exactly as I wanted it to:

     

     

     

    Filter(
     AddColumns(
     DemoWeeklyProjectHoursReporting,
     "ProjectDetails",
     LookUp(DemoProjectList,
     ID = MasterID)
     ),
     SortDate = Text(DatePickerWeekEnding.SelectedDate)
     )

     

     

    The Gallery fields are like this:

     

    ThisItem.ProjectDetails.CourseType.Value

    ThisItem.DevHours

     

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 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard