Reputation: 1102
MAX will take a range and tell me the largest number. But what if I wanted to iterate over that range and find the largest two numbers in a row?
For example, if I have the range [0, 2, 5, 6, 9, 3, 8], MAX is 9, but MAX2 is 15 (6+9). MAX3 is 20 (5+6+9).
How would I write MAX2, MAX3, or MAXN in Excel?
Upvotes: 4
Views: 2002
Reputation: 103
Thanks for this, the answer helped me solve an even more heinous problem:
=AVERAGE(LARGE(CHOOSE({1,2,3,4,5,6,7,8},(P3),(R3),(T3),(V3),(X3),(Z3),(AB3),(AD3)),ROW($1:$4)))
which let me average the largest of nonadjacent columns for a bunch of students.
Not that you asked but I figured someone might...
Upvotes: 0
Reputation: 166196
Eg: sum 3 largest numbers in A1:A5
=SUM(LARGE(A1:A5,ROW(1:3)))
This is an array formula, so you need to use use Ctrl
+Shift
+Enter
Upvotes: 8
Reputation: 137
=IF(AND(A4+A5>=A6+A5, A4+A5>=A3+A4),A4+A5,0)
you could use this formula to find the biggest two numbers in a row. and this would equate to max2
place your example range in column a and place the formula in b4. drag this from b:1-B:N and the number in b will correspond to the sum of the two highest cells that are next to each other
so if you had n=n you could do if(and(sum(a2:An)>=sum(a1:A(n-1), sum(a2:An)>=sum(An:A(n+n),sum(a2:an),0)
Upvotes: 0