Best way to access top N cells in a table column?

JenniferMurphy

Well-known Member
Joined
Jul 23, 2011
Messages
2,534
Office Version
  1. 365
Platform
  1. Windows
Is there a better (simpler, more compact) way to access the top N cells in a table column that what I did in this example?

Tables.xlsx
BCDEF
2N3
3Sum(N)1328257127
4
5ABCD
6539732
756871
83197394
910114756
106174496
11962583
First Value
Cell Formulas
RangeFormula
C3C3=SUM(OFFSET(Table9[[#Headers],[A]],1,0):OFFSET(Table9[[#Headers],[A]],N,0))
D3D3=SUM(OFFSET(Table9[[#Headers],[B]],1,0):OFFSET(Table9[[#Headers],[B]],N,0))
E3E3=SUM(OFFSET(Table9[[#Headers],[C]],1,0):OFFSET(Table9[[#Headers],[C]],N,0))
F3F3=SUM(OFFSET(Table9[[#Headers],[D]],1,0):OFFSET(Table9[[#Headers],[D]],N,0))
Named Ranges
NameRefers ToCells
'First Value'!N='First Value'!$C$2C3:F3


Thanks
 

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Here's an array option.

Book1
ABCDE
1N3
2Sum(N)1328257127
3
4ABCD
5539732
656871
73197394
810114756
96174496
10962583
Sheet5
Cell Formulas
RangeFormula
B2:E2B2=BYCOL(Table9,LAMBDA(t,SUM(TAKE(t,$B$1))))
Dynamic array formulas.
 
Upvote 0
Try
Excel Formula:
=SUM(TAKE(Table9[A],$C$2))

This is perfect. Thank you. This is a very useful function that I was not aware of.

Here's my implementation:

1711691701950.png


Tables.xlsx
BCDEF
2N3
3Sum(N)202023189
4Sum(3x2)40251320
5ABCD
656871
7539732
810114756
9962583
103197394
116174496
First n Values
Cell Formulas
RangeFormula
C3C3=SUM(TAKE(Table9[A],N,1))
D3D3=SUM(TAKE(Table9[B],N,1))
E3E3=SUM(TAKE(Table9[C],N,1))
F3F3=SUM(TAKE(Table9[D],N,1))
C4C4=SUM(TAKE(Table9[A]:Table9[B],3,2))
D4D4=SUM(TAKE(Table9[B]:Table9[C],3,2))
E4E4=SUM(TAKE(Table9[C]:Table9[D],3,2))
Named Ranges
NameRefers ToCells
'First n Values'!N='First n Values'!$C$2C3:F3
 
Upvote 0
The advantage is that the formula spills over automatically when you add a new column. Try to add column E and see what happen.
Aha! Thank you very much for the excellent and useful solutions.
 
Upvote 0
Aha! Thank you very much for the excellent and useful solutions.
If you look at the formula again, I should clarify that it's still using SUM() and TAKE(). With the additional BYCOL(), it applies SUM() and TAKE() to each of the columns in Table 9.

And you're welcome.
 
Upvote 0

Forum statistics

Threads
1,215,139
Messages
6,123,264
Members
449,093
Latest member
Vincent Khandagale

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top