Q: Formula help: count the number of blanks in a column "until..."
| name | string | metric |
|---|---|---|
| matthew | 5 | |
| mark | 1 | |
| mark | optimusPrime | |
| mark |
| |
| luke | 2 | |
| matthew | jamesLikesSteak | |
| john | 3 | |
| luke | lukingGood | |
| matthew | ||
| luke | ||
| john | johnnyPop | |
| john |
Hey guys--so I'm dealing with a bit of an issue in Numbers. I have a table in Numbers--the above table is a simplified representation of the relevant parts of the table. The left column "name" has a series of 12 repeated names and 0 missing values. The middle column "string" is a column that has lots of missing values per a formula based on another column that is not relevant to this problem. The ones that are not missing are all strings. The problem I'm having is with the right "metric" column:
I am trying to create a dynamic formula that will result in the numbers, and blanks, exactly as shown above. My goal is to create a formula that, for each row, counts the number of blanks in the "string" column until reaching a blank "string" that occurs next to the same "name" as in the row housing the formula--and if there is no such an occurrence, for it to be blank. So for instance, the second row (including the header row) has the name "matthew". The next time a blank "string" occurs next to the name "matthew" is in the tenth row. The number of blanks that occur between the second row and the ninth row is 5 (rows 2, 3, 5, 6, and 8). I have manually coded a small part of the table to use something like this (which would be housed in cell C2 in this example):
=IF(B2= "", COUNTBLANK(B2:B9), "")
This formula produces the correct number for the first data row (5), but it does not dynamically accomplish what I am trying to do since I'm trying to have the formula find the next blank "string" occurring next to the same "name" in the formula row.
I'm hoping someone has come across something like this before. I tried to go through all of the functions and formulas native to Numbers but so far I haven't found much success.
MacBook Pro (Retina, 15-inch, Mid 2015), OS X El Capitan (10.11.3)
Posted on Sep 7, 2016 2:48 PM
Hi BaronDe,
This is what I have come up with and as promised it is a little cumbersome.
I added a column (that can be hidden). This flags the name columns that have a blank string.
The real work happens here.
D4= COUNTBLANK(OFFSET($A$1,ROW(cell)−1,1,MATCH($A2,OFFSET($A$1,ROW(cell),2,ROWS($A, headers)−ROW(cell),columns),0),columns))
This relies on Columns A,B and C being as I have them.
The last OFFSET() creates a single column array in column C starting with the next row below and running to the end of the table.
MATCH() searches that array for the next case of the name in that row.
The first OFFSET() creates a single column array in column B that ranges from the current instance of the name to the next one that is next to a blank string.
COUNTBLANK() does its thing.
Your original metric column is on the right. I added data so it is no longer correct.
This formula fails when applied in a row with a string.
It throws an error when there are no other matching names.
I don't think these are fatal flaws.
Let me know if you have questions.
quinn
Posted on Sep 8, 2016 9:46 AM

