Get The First Rows Of A Collection

Input collection: myCars12

YearMake Model
2016ToyotaCorolla
2014HondaCivic
2019ToyotaCamry
2018HondaCivic
2018HyundaiElantra
2020HondaAccord


Output collection: mySolution12a

YearMake Model
2016ToyotaCorolla


Solution code:

//Create a collection
ClearCollect(myCars12,
{Year: 2016, Make: "Toyota", Model: "Corolla"},
{Year: 2014, Make: "Honda", Model: "Civic" },
{Year: 2019, Make: "Toyota", Model: "Camry" },
{Year: 2018, Make: "Honda",Model: "Civic"},
{Year: 2018, Make: "Hyundai", Model: "Elantra"},
{Year: 2020, Make: "Honda", Model: "Accord"}
);

//Get the first row only code
ClearCollect(
    mySolution12a,
    First(myCars12)
);


Output collection: mySolution12b

YearMakeModel
2016ToyotaCorolla
2014HondaCivic
2019ToyotaCamry


Solution code:

//Create a collection
ClearCollect(myCars12,
{Year: 2016, Make: "Toyota", Model: "Corolla"},
{Year: 2014, Make: "Honda", Model: "Civic" },
{Year: 2019, Make: "Toyota", Model: "Camry" },
{Year: 2018, Make: "Honda",Model: "Civic"},
{Year: 2018, Make: "Hyundai", Model: "Elantra"},
{Year: 2020, Make: "Honda", Model: "Accord"}
);

//Get the first rows code
ClearCollect(
    mySolution12b,
    FirstN(myCars12,3)
);