Select columns from 2d array

Hi Brainstrust,
I have an array of arrays. (ie a 2D array). That I would like to select some ‘columns’ from. Ie with the following intputs I would like the below output:

inputs

"input2darray": [
["Alice", "Bob", "Charles", "Diana", "Eve"],
["twoone", "twotwo", "twothree", "twofour", "twofive"],
["threeone", "threetwo", "threethree", "threefour", "threefive"]
]

"inputdesiredcolumnfirstrowvalues": ["Alice", "Diana"]

I can be confident that values in the first row of input2darray are unique

Output

"desiredoutputarray": [
["Alice", "Diana"],
["twoone", "twofour"],
["threeone", "threefour"]
]

Any help would be greatly appreciated.
Thanks

Welcome to the Make community!

Yes, that is possible. You’ll need a minimum of three modules.

Sample Input

Note: the order of the “selectedColumns” won’t matter :slight_smile:

Example

Here is an example of how your scenario could look:
Screenshot_2025-03-16_220332

This is just an example. Your final solution may or may not look like this depending on your requirements and data.

Example Output

Three columns selected based on the search array.

It is possible to do it in a single operation, but you’ll have to use a module that can run JavaScript code. An example of such a module that is completely free to use can be found here.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.