cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
PytByt
Post Prodigy
Post Prodigy

How to merge multiple collection into 1 single collection (with new column in it)

Hi all.. 

I already search the forum, but i haven't found similiar with my case here, 
I want to merge more than 5 collection into 1 single collection, but i dont understand how to do it right.

 

long story short, here is the code i use to gather my collection:

ClearCollect(
Iter1,
["A", "B", "C", "D", "E"]
);

ClearCollect(
Iter2,
["F", "G", "H", "I", "J"]
);

ClearCollect(
Iter3,
["K", "L", "M", "N", "O"]
);

ClearCollect(
Iter4,
["P", "Q", "R", "S", "T"]
);

ClearCollect(
Iter5,
["U", "V", "W", "X", "Y", "Z"]
);

ClearCollect(
Iter6,
["0", "1", "2", "3", "4"]
);

ClearCollect(
Iter7,
["5", "6", "7", "8", "9"]
);


ForAll(Iter1, Collect(BatchColl1, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));
ForAll(Iter2, Collect(BatchColl2, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));
ForAll(Iter3, Collect(BatchColl3, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));
ForAll(Iter4, Collect(BatchColl4, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));
ForAll(Iter5, Collect(BatchColl5, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));
ForAll(Iter6, Collect(BatchColl6, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));
ForAll(Iter7, Collect(BatchColl7, ShowColumns(Filter(ItemBatches,StartsWith(BatchNumber, Value)),"ItemNumber", "BatchNumber", "BatchExpirationDate")));

I also tried this formula, but it doesn't work:
Collect(ReleasedProductsColl, ShowColumns(Filter(ReleasedProductsV2, ProductGroupId = "10" && ProductGroupId = "20" && ProductGroupId = "40"), "ProductGroupId", "ItemNumber", "SearchName"))

Is my formula right?
if not, what is the simpliest way to achieve it?

And how i can merge all that BatchColl 1 through 7 together into 1 Collection only?

Please help.

 

BR.

pytbyt

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @PytByt ,

Could you please share a bit more about the target collection data structure you want to achieve?

Do you want to merge your BatchColl collection 1 through 7 into single one collection?

 

Based on the formula you provided to gather your BatchColl collection, I think it is right. If you want to achieve same functionality using easier way, please consider take a try with the following formula:

Concurrent(
             ClearCollect(Iter1, ["A", "B", "C", "D", "E"]),
             ClearCollect(Iter2, ["F", "G", "H", "I", "J"]),
ClearCollect(Iter3, ["K", "L", "M", "N", "O"]), ClearCollect(Iter4, ["P", "Q", "R", "S", "T"]), ClearCollect(Iter5, ["U", "V", "W", "X", "Y", "Z"]),
ClearCollect(Iter6, ["0", "1", "2", "3", "4"]), ClearCollect(Iter7, ["5", "6", "7", "8", "9"]) );
Collect(BatchColl1, ShowColumns(Filter(ItemBatches, BatchNumber in Iter1), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl2, ShowColumns(Filter(ItemBatches, BatchNumber in Iter2), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl3, ShowColumns(Filter(ItemBatches, BatchNumber in Iter3), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl4, ShowColumns(Filter(ItemBatches, BatchNumber in Iter4), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl5, ShowColumns(Filter(ItemBatches, BatchNumber in Iter5), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl6, ShowColumns(Filter(ItemBatches, BatchNumber in Iter6), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl7, ShowColumns(Filter(ItemBatches, BatchNumber in Iter7), "ItemNumber", "BatchNumber", "BatchExpirationDate"));

In addition, if you want to merge the BatchColl collection 1 through 7 into single one collection, please take a try with the following formula:

ClearCollect(MergedCollection, BatchColl1, BatchColl2, BatchColl3, BatchColl4, BatchColl5, BatchColl6, BatchColl7)

then you could use the MergedCollection as data source in your app.

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-xida-msft
Community Support
Community Support

Hi @PytByt ,

Could you please share a bit more about the target collection data structure you want to achieve?

Do you want to merge your BatchColl collection 1 through 7 into single one collection?

 

Based on the formula you provided to gather your BatchColl collection, I think it is right. If you want to achieve same functionality using easier way, please consider take a try with the following formula:

Concurrent(
             ClearCollect(Iter1, ["A", "B", "C", "D", "E"]),
             ClearCollect(Iter2, ["F", "G", "H", "I", "J"]),
ClearCollect(Iter3, ["K", "L", "M", "N", "O"]), ClearCollect(Iter4, ["P", "Q", "R", "S", "T"]), ClearCollect(Iter5, ["U", "V", "W", "X", "Y", "Z"]),
ClearCollect(Iter6, ["0", "1", "2", "3", "4"]), ClearCollect(Iter7, ["5", "6", "7", "8", "9"]) );
Collect(BatchColl1, ShowColumns(Filter(ItemBatches, BatchNumber in Iter1), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl2, ShowColumns(Filter(ItemBatches, BatchNumber in Iter2), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl3, ShowColumns(Filter(ItemBatches, BatchNumber in Iter3), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl4, ShowColumns(Filter(ItemBatches, BatchNumber in Iter4), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl5, ShowColumns(Filter(ItemBatches, BatchNumber in Iter5), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl6, ShowColumns(Filter(ItemBatches, BatchNumber in Iter6), "ItemNumber", "BatchNumber", "BatchExpirationDate"));
Collect(BatchColl7, ShowColumns(Filter(ItemBatches, BatchNumber in Iter7), "ItemNumber", "BatchNumber", "BatchExpirationDate"));

In addition, if you want to merge the BatchColl collection 1 through 7 into single one collection, please take a try with the following formula:

ClearCollect(MergedCollection, BatchColl1, BatchColl2, BatchColl3, BatchColl4, BatchColl5, BatchColl6, BatchColl7)

then you could use the MergedCollection as data source in your app.

 

Please consider take a try with above solution, then check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hello @v-xida-msft 

thank you for your reply and solution.

glad to have this community alive.

 

if my formula is already correct, then all i need to do is to merge the BatchColl collection 1 through 7 into single one collection.

 

thank you.

 

regards,

pytbyt

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

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