Extract name and value from row above in spreadsheet?

The following info isn't real but simulates the rows and columns that I'm dealing with without giving out sensitive info. Pretend I'm keeping track of runners for a league. I has the person that comes in first place with their name and the event, the date, and their time. There is usually over 100 people competing in the runs. I CANNOT change the order. I don't create the data, I'm just asked to manipulate it. And they don't want to turn on and off filters but have different sheets showing the raw data and the manipulated date.


They want to keep a running average for how well each person has done for the year.


The first list looks "something like"




WITHOUT using filters or a pivot table, they want to have a chronological list in alphabetical order showing something like:



So I have to be able to find the name of each person, their "place" which is one row ABOVE their name and put their name and their place into the second table. I can't figure out how to do that.


I don't produce the first table. I'm just asked to manipulate it into the format of the second table. I can do what I need to do from there. Again, this is just a made up simple thing LIKE what I'm trying to figure out. Where I have to find a name and then the number ABOVE it and put the number next to the correct name in the next column (for that date).


Hopefully that isn't too confusing.


Apple TV 4K, tvOS 18

Posted on Jan 5, 2026 12:45 PM

Reply
Question marked as Top-ranking reply

Posted on Jan 5, 2026 2:38 PM

I took a run at this with the data provided, and some assumptions, and I think I'm close.


What I can't determine is where you're getting the other values from in your sample Table 2 - for example, nowhere in your source data does 'Betty' have a '82'. I'm assuming, for now, that this is just because you're showing a subset of the data.


Either way, using the sample data in Table 1, and creating a new Table 2, I came up with three formulas that result in a table that looks like:



The three magic formulae are:


A2:


=SORT(UNIQUE(TOCOL(FILTER(Table 1::B:C,Table 1::$A="Name",""))),1)


Starting from inside the parentheses, it performs a FILTER() on 'Table 1::B:C' to get a list of all the cells where Table 1::A is 'Name' - in other words, it extracts all the names from the table.


This is then run through TOCOL() to get a one-dimensional list of names.


This list is run through UNIQUE() to get a list of unique names


This list of unique names is then run through SORT() to sort them and ends up with the values in Table 2::A


A similar function is applied to B2 to get a list of unique dates:


=SORT(UNIQUE(TOROW(FILTER(Table 1::B:C,Table 1::$A="Date",""),1,TRUE),TRUE,FALSE),1,,TRUE)


It's a little more complicated since we use TOROW() to get a horizontal list of dates, rather than a vertical list, but the concept is the same - get all the 'date' cells, turn them into a single row, extract uniques and sort the result.


As long as Table 2 is large enough (has enough rows for all the unique names, and enough columns for all the unique dates), this should set your table headers up correctly.


Now comes the complex part - a formula that takes the name from column A, and the date from row 1 and finds the matching 'Place'.


(Note, my first pass here was overly complex, performing multiple LOOKUP()s and OFFSET()s, but eventually I settled on an easier path...)


Using a similar technique to getting the unique names and dates, it's easy to get a list of all names and all dates as listed in the source table. Create a third list of all the 'Placed 1', and you can easily perform a filter to get the answer you're looking for.


In Table 2::B2, set the formula to:


=IFERROR(
    LET(
        names,TOCOL(FILTER(Table 1::$B:$C,Table 1::$A="Name")),

        dates,TOCOL(FILTER(Table 1::$B:$C,Table 1::$A="Date")),

        places,TOCOL(FILTER(Table 1::$B:$C,Table 1::$A="Placed 1",)),

        FILTER(places,(names=$A2)×(dates=B$1))
    )
,"")


LET() allows you to run a formula and store its results in a variable for later use.

In this case, I create three variables, labelled 'names', 'dates' and 'places'. Each of these run a similar FILTER() against the source data to extract the relevant values.

This is done using the basic FILTER() as above, but without the UNIQUE() and SORT() values since I want all names and dates, including duplicates, in the order they appear on the source table.

Once I have those, I can simply FILTER() the places data to return only results where the name is the name in $A2 (i.e. 'Betty', in this case), and where the date is the value in B$1 (i.e. '8/17/25')


The LET() is wrapped in an IFERROR() function to catch cases where a runner didn't run/place on a given date.


The last step is to fill this formula across all the columns, and down all the rows, to cover all dates and runners.


Violà

7 replies
Question marked as Top-ranking reply

Jan 5, 2026 2:38 PM in response to Camelot

I took a run at this with the data provided, and some assumptions, and I think I'm close.


What I can't determine is where you're getting the other values from in your sample Table 2 - for example, nowhere in your source data does 'Betty' have a '82'. I'm assuming, for now, that this is just because you're showing a subset of the data.


Either way, using the sample data in Table 1, and creating a new Table 2, I came up with three formulas that result in a table that looks like:



The three magic formulae are:


A2:


=SORT(UNIQUE(TOCOL(FILTER(Table 1::B:C,Table 1::$A="Name",""))),1)


Starting from inside the parentheses, it performs a FILTER() on 'Table 1::B:C' to get a list of all the cells where Table 1::A is 'Name' - in other words, it extracts all the names from the table.


This is then run through TOCOL() to get a one-dimensional list of names.


This list is run through UNIQUE() to get a list of unique names


This list of unique names is then run through SORT() to sort them and ends up with the values in Table 2::A


A similar function is applied to B2 to get a list of unique dates:


=SORT(UNIQUE(TOROW(FILTER(Table 1::B:C,Table 1::$A="Date",""),1,TRUE),TRUE,FALSE),1,,TRUE)


It's a little more complicated since we use TOROW() to get a horizontal list of dates, rather than a vertical list, but the concept is the same - get all the 'date' cells, turn them into a single row, extract uniques and sort the result.


As long as Table 2 is large enough (has enough rows for all the unique names, and enough columns for all the unique dates), this should set your table headers up correctly.


Now comes the complex part - a formula that takes the name from column A, and the date from row 1 and finds the matching 'Place'.


(Note, my first pass here was overly complex, performing multiple LOOKUP()s and OFFSET()s, but eventually I settled on an easier path...)


Using a similar technique to getting the unique names and dates, it's easy to get a list of all names and all dates as listed in the source table. Create a third list of all the 'Placed 1', and you can easily perform a filter to get the answer you're looking for.


In Table 2::B2, set the formula to:


=IFERROR(
    LET(
        names,TOCOL(FILTER(Table 1::$B:$C,Table 1::$A="Name")),

        dates,TOCOL(FILTER(Table 1::$B:$C,Table 1::$A="Date")),

        places,TOCOL(FILTER(Table 1::$B:$C,Table 1::$A="Placed 1",)),

        FILTER(places,(names=$A2)×(dates=B$1))
    )
,"")


LET() allows you to run a formula and store its results in a variable for later use.

In this case, I create three variables, labelled 'names', 'dates' and 'places'. Each of these run a similar FILTER() against the source data to extract the relevant values.

This is done using the basic FILTER() as above, but without the UNIQUE() and SORT() values since I want all names and dates, including duplicates, in the order they appear on the source table.

Once I have those, I can simply FILTER() the places data to return only results where the name is the name in $A2 (i.e. 'Betty', in this case), and where the date is the value in B$1 (i.e. '8/17/25')


The LET() is wrapped in an IFERROR() function to catch cases where a runner didn't run/place on a given date.


The last step is to fill this formula across all the columns, and down all the rows, to cover all dates and runners.


Violà

Jan 5, 2026 1:13 PM in response to OlsonBW

What's missing from your post is how much detail you start with in the second table.


Is the second table supposed to identify and extract the runners' names to populate the first column? or is that something that you compile manually?


Are the dates in the top row of the second table entered manually? or are the dates supposed to auto-populate based on the source data?


If you manually compile the list of names and manually define the date headings, this doesn't seem too far-fetched. If the second table is supposed to be completely autonomous and find all possible runners' names and race dates, that's a whole other level of effort.

Jan 5, 2026 5:04 PM in response to Camelot

"They" don't want me using actual data in my examples so I have to create something that "looked" like a tiny bit of the data they have. But the most important details are there. Those details being that the number they want to get (which you provided a solution for) is above the name. Everything was easy for me to get using VLOOKUP but the number above the name had me stumped. Also, I didn't want to give you more because when I do people often don't read what I write and instead they look at my test data and they assume that I want something that I didn't ask for. But you didn't "assume" and you gave me something that worked. Thank you again.


My normal way of learning software (including programming) is going through all the menus and trying to use everything in them to create things and then later if I needed to do something, I probably would have done it already and it was just a matter of remembering what I did and looking spreadsheets I had saved that might have what I needed.


I was a programmer for 40 years but my memory took a HUGE hit due to diabetes and the medications I have to control it. It was so bad I had to retire early but I still try to help out when I can and thankfully they appreciate it. Unfortunately memory recall is about 30% of what it used to be. I really appreciate your help. And yes, I'm working with doctors on it but they don't seem to have anything that is helping.

Jan 5, 2026 5:37 PM in response to Camelot

To answer your question. The table they are giving me is a CSV file which I'm opening up with Numbers. Each name has about 25 pieces of information with it and there are 3,000 names in each column. Each column has various number of names with their data with it. Each column could have 100% totally unique names, 100% duplicate (with just new data on a new date) or a mix of unique and non-unique names with the data.


This is a subset of their master list which has more information for each person which wasn't needed for the report they wanted.


Each column has the Date, "Place", Name, (those are the important three, everything else is easy to get for me).

Jan 5, 2026 5:48 PM in response to OlsonBW

All of my programming was on PCs with DOS, OS/2, Linux and a few other OSs using mostly C and JAVA but also VisualBasic (Excel) when I HAD to. I also wrote print drivers because we had unique printing needs. And for quick things I would create large spreadsheets in Lotus 1-2-3 (including creating a character sheet for D&D and putting ALL of the information from 18 different D&D books into the spreadsheet. Anything you typed into the character sheet would pull up information from any of the books and would reflect in the character stats and I also had dice rolls and everything in it.


I also created complex WordPerfect scripts back when they had the SIGNIFICANTLY BETTER WP scripting language before they replaced it #$*(#$ VB. Just because I could program in something didn't mean I had to like it.


I also made databases in over a dozen different database engines with a couple databases of over a million items in the database.


So I USED to be good at programming/scripting and I'm fighting to keep being able to do fun things. And these ARE fun for me. Yes, I'm a nerd. lol

Jan 6, 2026 9:46 AM in response to OlsonBW

> "They" don't want me using actual data in my examples so I have to create something that "looked" like a tiny bit of the data they have. But the most important details are there.


I figured that was the case... I couldn't see any other way that Betty could score 82, unless there was more missing data that my formulas weren't seeing. Glad it worked out.


Also, I forgot to mention that my formula to extract the values does depend on the consistency of the source data.


If there are a mismatched number of 'Name', 'Date' and 'Placed 1' rows, it may return a different/incorrect value.


For example if, for some reason, there was an extra 'Name' row in one of the competitor's entries, this would trigger an off-by-one bug, because the filter would identify the nth name for the given date, and return the corresponding nth value in the places array, not realizing there's an extra name in the middle.


Shouldn't be a big problem if the data is clean. Just something to be aware of.

Extract name and value from row above in spreadsheet?

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.