Originally Posted by

**Drew Goldberg**
I have never used the majority of the key formulas used in your solutions so I'm going through the excercise of trying to learn their function

Good for you - most would not bother so kudos.

To help out where I can I will, using the file I uploaded, go through a few formulae to try and explain the mechanics...

What this is doing is counting the downtime instances... these are denoted by:

So using the example data of Brand A in Row 2 such that B2:I2:

Here we have 3 instances ... denoted as follows:

We use O1 to enable us to restrict the amount of calculations we perform... ie we need only calculate x number of rows where x = number of downtimes to be listed.

For more detailed explanation of Sumproduct see Bob Phillips' white paper on the Function - see SUMPRODUCT link in my sig.

When faced with lengthy formulae it's best to split out into component parts... we can see in short the function follows the basic construct of:

So let's first look at the test in the IF:

This is where we're establishing as to whether or not we need conduct calcs based on number of instances to be reported... if the Rows processed thus far in our table exceed the value of O1 we know there are no more instances to report so if this test returns TRUE we simply return a Null value to O, if FALSE we will continue and calculate the SMALL function. We can establish ROWS processed by seeing how many rows are included from the first row of the results table (O2) to the current row ... in the case of O2 the answer is obviously 1 (ie ROWS(O$2:O2) - 1 row in range), whereas as the formula is copied down the latter range will increment... so by the time we get to O8 we have 7 rows (ROWS(O$2:O8)), this would exceed O1 (6) so we return a Null.

That's the simple bit over...

What we're trying to achieve in the above is to return a unique number which will give us all of the info we need to determine the location of a given downtime which we need to report... in essence cells can be located by their row & column positions... ie row 10 column 4 is D10 as row 1 column 1 is A1, so what we're trying to do is build a number which gives us the row & column information.

I decided to do this using a number convention of:

where 10.004 would be D10, 1.001 would be A1, 3.027 would be AA3 etc...

What the formula does is to first identify the appropriate cells which mark the commencement of a downtime (using similar logic to the Sumproduct as used in O1), ie:

and the number is generated using

ie take the ROW of the cell and add to that the COLUMN of the cell divided by 1000 (such that the COLUMN value becomes a decimal value and does not affect therefore affect the ROW value)

So put together this becomes:

We put this into a SMALL function such that we can generate an Array of all the values representing all the instances of downtimes:

The key then becomes the value of k ...

SMALL as you will have worked out works along the lines of:

eg

returns the 3rd smallest value in the array of values, ie 3

In our case k is determined by how many rows we've processed in our results table... if we're on the first row of our results table then we want the smallest value, if we're on the 6th row of our results table we want the 6th smallest value (ie the largest given we have only 6 values in our array (O1))

So this as you can see is the same logic as used previously to establish whether or not to return a Null... ie use ROWS(N$2:N2) to establish k... as you can see I've used N here - there is no significance to the Column ... it could be A, ZZ etc... what is important is the row value .. the first row reference ($2) is absolute (first row in table) whereas the latter row is relative such that as we progress the formula down the table the count of rows will increment.

So using this Array formula in O we generate a list of unique numbers and Nulls, using the sample file we end up with:

From these values we can now retrieve information given we know thesee values translate to:

I will do the remainder of formulae in a subsequent post...

## Bookmarks