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
Super User

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
Super User

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
Super User

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
Super User

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
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,960)