You need to create an array of terms for "k" in the LARGE function.
Where
a) "k" will range from 1 to n
b) n being the lesser of max terms (in this instance 8) and count of available terms
EDIT: the use of 8 and subsequent MIN function is optional and is not actually in the initial formula ... so you can disregard the MIN function elements - it doesn't affect the underlying logic
we can create that array by using ROW and an appropriate range reference, the starting point for which will always be row 1 and the end point determined by b)
To generate b) we use INDEX with the MIN & COUNT,eg:
If there are 10 numeric values within the specified range the INDEX will return A8, if there were five numeric values within the specified range INDEX will return A5
INDEX can return either value or range pending the context in which it's used... in this case it's being used in range form:
range form given i) use of colon (range delimiter) and ii) use of ROW which expects a range input
Using the 10 term example the above would equate to
ie lesser of 8 and 10 is used
Using the 5 term example
In conjunction with an Array formula the above use of ROW will generate the requisite "k" array for use with encompassing LARGE, eg:
10 terms (uses 8 as this the "cap"):
5 terms:
So putting it altogether, step by step using the 10 term example:
For 5 terms the only difference is from step 3 onwards as the output of the MIN would be 5 rather than 8... this is to ensure where fewer valid values exist than desired (8) the function adapts accordingly so as to avoid error.
I hope that helps.
Bookmarks