Group By And Find The AVERAGE

Input collection: myTravelExpenses10

DateItemValue
1/1/2020Hotel1050
1/1/2020Food30
1/2/2020Food75
1/3/2020Hotel1300
1/3/2020Food50
1/4/2020Flight800


Output collection: mySolution10

ItemAverage Value
Hotel1175
Food51.66666667
Flight800


Solution code:

//Create a collection
ClearCollect(myTravelExpenses10,
{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 average code
ClearCollect(
    mySolution10,
    DropColumns(
        AddColumns(
            GroupBy(myTravelExpenses10,"Item","GroupedItems"),
        "Average Value",Average(GroupedItems,Value)
        ),
    "GroupedItems"
    )
);