How do I count rows that match in order?

My question is this... and its a multipart question.


I have one column of numbers that have matches. I need to know how many of those there are and then take each one of those rows and number them in order starting at 1.


So first match of 3 would be 1 and the next being 2 and then the next being 3.

As seen in the golden ORDER Column.


Next I need to take the MEMBERID and merge them together on another table.

As seen with the Blue Arrows.


Then I need to move the FILE cells into that other table into their own Column.

As seen with the Red Arrows.


How do can that be done?


Thanks

Posted on Oct 27, 2022 5:03 AM

Reply
12 replies

Oct 27, 2022 6:16 AM in response to MrN8_FBO

And one way to get the file names in the columns would be to do something like this:




Add an "index" column to the first table. In F2, filled down, I have this formula:


=A2&B2


Then in the table with the distinct values for MembershipID I have this in B2, filled right and down:


=XLOOKUP($A2&COLUMN()−1,Table 1::$F,Table 1::$E,"")


Replace the , in the formulas with ; if your region uses , as a decimal separator.


SG

Oct 27, 2022 10:03 AM in response to MrN8_FBO

Here is another way to get the file names into the table, once you have the list of unique member IDs:



The first table needs a column of index numbers. You can use =ROW()-1

Column B is SGIII's COUNTIF formula


The formula in the second table is

=OFFSET(Table 1::$E$1,SUMIFS(Table 1::$F,Table 1::$A,$A,Table 1::$B,COLUMN()−1),0)

All cells other than the Member ID column and header row get that formula.


If you don't like "FileID" to show as the default value, you can create a custom highlighting rule of "Text is FileID" and set the text opacity to zero or set it to white text.


The formula uses SUMIFS as a way to do a multi-condition lookup.

Oct 28, 2022 8:57 PM in response to MrN8_FBO

If your data table is like the one you posted but with the addition of a date column, you can sort it descending according to date then use the same formulas already provided (the first file for each memberID will be the most recent one). Because of a longstanding bug in Numbers, the COUNTIF column will end up with reference errors when sorted so you'll either have to redo that column or use a workaround formula that is sort-safe (it uses OFFSET to create the range in the formula).


It can also be done with the table completely unsorted. Here is one method similar to SGIII's earlier formulas:



Table 1 column G formula =A&(F=MAXIFS(F,A,A))

This locates the row with the maximum date&time value for each Member ID


Table 2 column B formula =XLOOKUP($A&"TRUE",Table 1::$G,Table 1::$E,"",0)&""


For the Table 2 formula I added &"" to the end. Without it the result of the formula will be "0" if Table 1 and Table 2 have any empty rows. With it the result will be "". It forces the result to be a string but that should be okay here.

Oct 28, 2022 9:14 AM in response to SGIII

I got that to work the way I needed it. But I have another question with this same project.


I have many members with multiple files right... Each file has a date as to when they were uploaded. I need to have the other table to just show me the most recent one of the two or more files. I dont really care about the older ones that were done 5 years ago.


Thanks

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How do I count rows that match in order?

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