UNIQUE Records In A Collection

Input collection: myTrucks2

YearMakeModel
2020FordF150
2018ChevySilverado
2020FordF150
2020FordF150
2017NissanFrontier
2016GMYukon
2016GMYukon


Output collection: mySolution2

YearMakeModel
2020FordF150
2018ChevySilverado
2017NissanFrontier
2016GMYukon


Solution code:

//Create a collection
ClearCollect(myTrucks2,
    {Year: 2020, Make: "Ford", Model: "F150"},
    {Year: 2018, Make: "Chevy", Model: "Silverado" },
    {Year: 2020, Make: "Ford", Model: "F150" },
    {Year: 2020, Make: "Ford", Model: "F150"},
    {Year: 2017, Make: "Nissan", Model: "Frontier"},
    {Year: 2016, Make: "GM", Model: "Yukon"},
    {Year: 2016, Make: "GM", Model: "Yukon"}
);

//Duplicate removal code
ClearCollect(mySolution2,ForAll(Distinct(myTrucks2, ThisRecord),ThisRecord.Value));