Input collection: mySales4
ProductID | QuantitySold |
1001 | 4 |
1002 | 5 |
1001 | 7 |
1000 | 1 |
1000 | 8 |
Input collection: myProduct4
ProductID | ProductName | UnitPrice | Stock |
1000 | Jacket | 70 | 10 |
1001 | T-Shirt | 30 | 4 |
1002 | Baseball Cap | 20 | 8 |
Output collection: mySolution4
ProductID | QuantitySold | ProductName | UnitPrice | InStock |
1001 | 4 | T-Shirt | 30 | 4 |
1002 | 5 | Baseball Cap | 20 | 8 |
1001 | 7 | T-Shirt | 30 | 4 |
1000 | 1 | Jacket | 70 | 10 |
1000 | 8 | Jacket | 70 | 10 |
Solution code:
//Create two collections
ClearCollect(myProduct4,
{ProductID: "1000", 'ProductName': "Jacket", UnitPrice: 70},
{ProductID: "1001", 'ProductName': "T-Shirt", UnitPrice: 30},
{ProductID: "1002", 'ProductName': "Baseball Cap", UnitPrice: 20}
);
ClearCollect(mySales4,
{ProductID: "1001", QuantitySold: 4},
{ProductID: "1002", QuantitySold: 5},
{ProductID: "1001", QuantitySold: 7},
{ProductID: "1000", QuantitySold: 1},
{ProductID: "1000", QuantitySold: 8}
);
//Add all columns from another table code
ClearCollect(mySolution4,
Ungroup(
DropColumns(
AddColumns(
mySales4,
"myGroupedColumn",
Filter(
myProduct4,
ProductID=mySales4[@ProductID]
)
),
"ProductID"
),
"myGroupedColumn"
)
);