Input collection: myTravelExpenses7
Date | Item | Value |
1/1/2020 | Hotel | 1050 |
1/1/2020 | Food | 30 |
1/2/2020 | Food | 75 |
1/3/2020 | Hotel | 1300 |
1/3/2020 | Food | 50 |
1/4/2020 | Flight | 800 |
Output collection: mySolution7
Item | Max Value |
Hotel | 1300 |
Food | 75 |
Flight | 800 |
Solution code:
//Create a collection
ClearCollect(myTravelExpenses7,
{Date: Date(2020,1,1), Item: "Hotel", Value: 1050},
{Date: Date(2020,1,1), Item: "Food", Value: 30 },
{Date: Date(2020,1,2), Item: "Food", Value: 75 },
{Date: Date(2020,1,3), Item: "Hotel",Value: 1300},
{Date: Date(2020,1,3), Item: "Food", Value: 50},
{Date: Date(2020,1,4), Item: "Flight", Value: 800}
);
//Group by and maximum column code
ClearCollect(
mySolution7,
DropColumns(
AddColumns(
GroupBy(myTravelExpenses7,"Item","GroupedItems"),
"Max Value",Max(GroupedItems,Value)
),
"GroupedItems"
)
);