Remove All Columns From A Collection Except

Input collection: myTeams44

TeamPerson1Person2Person3
Team AJen PhillipsLeonard PetersenMurray Cole
Team BPercy WaltersAdam DavidsonAlice Lemon
Team CSarah DavyMelissa StevensBernice Friesen


Output collection: mySolution44a (show only ‘Team’ column)

Team
Team A
Team B
Team C


Solution code:

//Create a collection
ClearCollect(myTeams44,
{Team: "Team A", Person1: "Jen Phillips", Person2: "Leonard Petersen", Person3: "Murray Cole"},
{Team: "Team B", Person1: "Percy Walters", Person2: "Adam Davidson", Person3: "Alice Lemon"},
{Team: "Team C", Person1: "Sarah Davy", Person2: "Melissa Stevens", Person3: "Bernice Friesen"}
);

//Remove all columns except a single column code
ClearCollect(mySolution44a, ShowColumns(myTeams44,"Team"));


Output collection: mySolution44b (show only ‘Team’ & ‘Person1’ column)

TeamPerson1
Team AJen Phillips
Team BPercy Walters
Team CSarah Davy


Solution code:

//Create a collection
ClearCollect(myTeams44,
{Team: "Team A", Person1: "Jen Phillips", Person2: "Leonard Petersen", Person3: "Murray Cole"},
{Team: "Team B", Person1: "Percy Walters", Person2: "Adam Davidson", Person3: "Alice Lemon"},
{Team: "Team C", Person1: "Sarah Davy", Person2: "Melissa Stevens", Person3: "Bernice Friesen"}
);

//Remove all columns except multiple columns code
ClearCollect(mySolution44b, ShowColumns(myTeams44,"Team","Person1"));