cancel
Showing results for
Did you mean:
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

 A 1 B 2 C 3
1 ACCEPTED SOLUTION

Accepted Solutions
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.

5 REPLIES 5
Super User

Hi @CP0822 ,

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

Helper I

Hi Warren @WarrenBelz

Yes, I need to combine them in their current order

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,
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.

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.

Helper I

Yes, works fine.

Announcements

#### Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

#### Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (2,808)