Hi all,
Like my subject line says, I am wondering how I can create a collection that combines data from multiple collections. In an app I have, there are 5 different collections that do different things. Each collection does record a "Part #" amongst other things, and I would like to create a collection that grabs the "Part #" from each of these collections.
My collections are "colConnectors", "colAccessories", "colSeals", and "colTerminals"
I am imagining using ClearCollect on a button's OnSelect property to create this collection of collections. I had tried to do something like:
ClearCollect(colAllParts, {'Part #': ForAll(colConnectors, PartNumber) || ForAll(colTerminal, EndTerminal))
But is obviously not working. Can anyone help point me in the right direction for generating this list?
How would I go about showing every single record in colAllPartsGrouped?
For example, part 1AA might be used for multiple connectors in my connector collection. However, when I use GroupBy I only get 1 record for each part number - even if there are multiple. I realize that the additional records are nested inside the table created when using GroupBy, but is there an easy way to show the number of times each part appears?
Your initial solution was very helpful for getting me started, I appreciate your feedback.
One approach is to group the *PartNumber column:
ClearCollect(colAllParts, colConnectors,colAccessories,colSeals,colTerminals);
ClearCollect(colAllPartsGrouped, GroupBy(colAllParts, "PartNumber", "_groupedRecords"))
This gives you a tidy list of unique PartNumbers and a table of all records for each PartNumber:
Then if you want to fetch all records for example, for PartNumber 1AA, you simply have to LookUp that part number from the collection:
LookUp(colAllPartsGrouped, PartNumber="1AA")._groupedRecords
This screenshot is an example for a DataTable:
* This assumes all collections have identical column names for PartNumber, if not you will want to AddColumns (or RenameColumns) when building the initial collections to have this common column name.
For example, if a list called testList has Part_x0023_ as the column name, you can duplicate this column in a new column called "PartNumber" when collecting:
ClearCollect(colExample,AddColumns(testList,"PartNumber",Part_x0023_ ) );
There are many answers to this question I found: Maybe one of them will be a solution you can use too?
https://powerusers.microsoft.com/t5/Building-Power-Apps/Combine-2-Collections-into-1/td-p/1320819
https://powerusers.microsoft.com/t5/Building-Power-Apps/Merge-Two-collections/td-p/956031
https://powerusers.microsoft.com/t5/Building-Power-Apps/Merge-two-collections/td-p/1404555
Hope this is helpful.
WarrenBelz
146,651
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,999
Most Valuable Professional