How to Filter Table Values by Column Name (in Formulas)

Hey all!

I’m struggling with a very similar problem and haven’t been able to figure it out from the above unfortunately :confused: it would be great if you could kindly help!

In short, I have two tables - one that has a list of columns with names like protein, carbs, etc etc, then I have a second table which has the same names but listed as rows.

My goal is to input a sorted list of the items into the rows, so for instance, Column 1 will say ingredient name, and column 2 will say the three ingredients that contain the most amount of that nutrient.

Since I’ll have around 30 columns (vitamins etc), is there a way to do this programmatically?

Happy to do it manually if needed, just really eager to get it sorted, so any thoughts you can add would be much appreciated!

Thank you!!

Here’s what I’ve got so far: