MacMost Q&A Forum • View All Forum QuestionsAsk a Question

How Do I Create a List Of Values From a Two-Dimensional Table?

I have an n x m table , n (rows) are years, m (cols)are months, values are temperatures.
How can I create a vector just containing the values in the correct sequence?

E.G In
Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec
1950 x1 x2 x3 x4 x5 x6 x7 x8 x9 x10 x11 x12
2021 y1 y2 y3 y4 y5 y6 y7 y8 y9 y10 y11 y12

1950-01 n1
1959-02 n2

2021-12 m12

This should be easy no? But I can only find a complex, nested, messy function on youtube.

I wish to create a single vector as input to a graph with dates (yyyy-mm) on the x-axis and temperatures on the y-axis
Some climate sites show their data in the form I’ve described eg.


Comments: 3 Responses to “How Do I Create a List Of Values From a Two-Dimensional Table?”

    2 years ago

    There's no easy way. But if you use the INDEX function you can construct another table that does it. Assume your first table is named "Temps" and column A is years, row 1 is months, but as numbers: 1-12.

    So the first data row of the other table would be 2 and 2 in the first two columns (Cells A2 and B2). Then the two columns would be 2,3 then 2,4, down to 2,12 and then 3,2 and 3,3, etc.

    This gets you those values like "1950-01" in column C.

    Seems complex, but a lot of it is just to deal with showing the month like 01 instead of 1. Otherwise, it would be:

    This would create a real date value and you could format that column any way you like.

    Then a simpler INDEX function gets you the temperature

    Then you can hide columns A and B if you like.

    Another way to do it would be to use INDEX with the entire table in the first parameter, then MATCH for the row and MATCH for the column. So like this:

    INDEX(Temps::A:M, MATCH(1950,Temps:A), MATCH(1,Temps:$1:$1))

    But that can be more complex depending on what you are used to.

    2 years ago

    Thanks Gary, that works! Creating your other table is time consuming when the 'Temps' table is large.
    I mentioned a messy solution on YouTube - , he shows this formula
    It works in EXCEL, bur errors in NUMBERS, can this be fixed? Thanks in advance

    2 years ago

    Pete: Lots wrong in that formula. Look up each function in Numbers and compare the examples. For instance, COLUMNS needs a range, and you are only giving it the name of a table. See how I use it in my example.

Comments Closed.