cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
CP0822
Helper I
Helper I

Combining Two collections

Hi guys,

 

Let's say I have the following scenario. What I need is a third collection but combining the two collections like this. Any ideas of how to achieve this? These are completely independent collections, I can't use a lookup formula and these two collections will always have 1 column and the same number of rows.

 

Thanks

 

Collection 1

A

B

C

 

Collection 2

1

2

3

 

Collection 3

A1
B2
C3
1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @CP0822 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

5 REPLIES 5
WarrenBelz
Super User III
Super User III

Hi @CP0822 ,

I am assuming you want to combine these simply in the order that are currently set in?

Hi Warren @WarrenBelz 

 

Yes, I need to combine them in their current order

WarrenBelz
Super User III
Super User III

Hi @CP0822 ,
Firstly as you will see below, this is not straight-forward  - I will give you my entire test code - you will not need the top two bits as they are simply making the two test collections, but one thing you should take away from it is to not have your field names called "Value" as you need this elsewhere in the code.

//These are the two test collections
ClearCollect(
   col1,
   {Field1: "a"},
   {Field1: "b"},
   {Field1: "c"},
   {Field1: "d"},
   {Field1: "e"}
);
ClearCollect(
   col2,
   {Field2: 11},
   {Field2: 12},
   {Field2: 13},
   {Field2: 14},
   {Field2: 15}
);

//Now add a row number to the first
Clear(col1A);
With(
   {wList: col1},
   ForAll(
      Sequence(CountRows(wList)),
      Collect(
         col1A,
         Patch(
            Last(
               FirstN(
                  wList,
                  Value
               )
            ),
            {RowNo1: Value}
         )
      )
   )
);

//now add a row number to the second
Clear(col2A);
With(
   {wList: col2},
   ForAll(
      Sequence(CountRows(wList)),
      Collect(
         col2A,
         Patch(
            Last(
               FirstN(
                  wList,
                  Value
               )
            ),
            {RowNo2: Value}
         )
      )
   )
);

//Now combine them into a third collection
Clear(col3);
Collect(
   col3,
   AddColumns(
      col1A,
      "OtherField",
      LookUp(
         col2A,
         RowNo2 = RowNo1
      ).Field2
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

WarrenBelz
Super User III
Super User III

Hi @CP0822 ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

CP0822
Helper I
Helper I

Hi @WarrenBelz 

 

Yes, works fine.

 

Thanks for your support

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Don't miss the call this month on June 16th - 8a PDT

Top Solution Authors
Top Kudoed Authors
Users online (63,427)