Array of SUMs?

BrianGGG

Board Regular
Joined
Mar 5, 2016
Messages
62
Hello.

I have a simple set of numbers as below:


BCD
73456
74789
75101112
76323

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Summary





I'd like to return an array of column sums rather than the grand total sum of all numbers, e.g. my desired answer is {24;26;30} rather than 80.
However, any syntax that I give to sum (e.g. SUM(b73:d76), etc.) gets mashed up into a single total.

My goal is to write a single formula to "spill" across the columns with the new dynamic arrays (rather than copy the formula across). Any array function (with or without the new dynamic array functions like SEQUENCE) will work for me.

Any ideas?


thanks
BrianGGG
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Array-enter (press ctrl+shift+Enter instead of just Enter) a formula that contains the following:

SUM(INDEX(B73:D76,0,{1,2,3}))

or more generally:

SUM(INDEX(B73:D76,0,COLUMN(B73:D73)-COLUMN(A73)))

But that produces a horizontal array of 3 columns, the equivalent of {24,26,30}.

The syntax {24;26;30} is a veritcal array of 3 rows. Do you require the vertical array?
 
Last edited:
Upvote 0
Array-enter (press ctrl+shift+Enter instead of just Enter) a formula that contains the following:

SUM(INDEX(B73:D76,0,{1,2,3}))

or more generally:

SUM(INDEX(B73:D76,0,COLUMN(B73:D73)-COLUMN(A73)))

Have you tested these?

Both resolve to simply:

=SUM(B73:B76)

and not to how you would wish.

You can use SUBTOTAL and OFFSET here, though I prefer the non-volatile

MMULT(TRANSPOSE(ROW(B73:D76)^0),B73:D76)

which, suitably coerced (i.e. within some external function and committed with CSE), will produce:

{24,26,30}

which can be transposed if desired.

Regards
 
Upvote 0
Array-enter (press ctrl+shift+Enter instead of just Enter) a formula that contains the following:
SUM(INDEX(B73:D76,0,{1,2,3}))
or more generally:
SUM(INDEX(B73:D76,0,COLUMN(B73:D73)-COLUMN(A73)))
Have you tested these?

I did. In Excel 2010, I select 3 horizontal cells and array-enter either formula (press ctrl+shift+Enter instead of just Enter). The result is 24, 26 and 30 respectively.

BTW, we can get a vertical array by selecting 3 vertical cells and array-entering the following:

=SUM(INDEX(B73:D76,0,{1;2;3}))
or:
=SUM(INDEX(B73:D76,0,TRANSPOSE(COLUMN(B73:D73)-COLUMN(A73))))

I was surprised that =TRANSPOSE(SUM(INDEX(B73:D76,0,{1,2,3}))) does not work, array-entered of course.

PS.... Having said and demonstrated as much, I should say that nevertheless, there might be contexts where embedding the expression SUM(INDEX...) does not work, even when array-entered. We both know that there are expressions where Excel inexplicably does not treat the embedded expression as an array. XOR LX is expert at finding creative, albeit contorted, ways to fool Excel into delivering embedded arrays.
 
Last edited:
Upvote 0
Unfortunately, I am using the Insider Edition of Excel 2016 along with Dynamic Arrays.
There is no such thing as CSE anymore ...

And the following: SUM(INDEX(B73:D76,0,{1;2;3}))
does not work for me.

I have been trying to use some coercion myself, most notably the N(IF(1))) tricks...and none of them seem to return the right values.
I think SUM is a lost cause here, and I'm hoping/praying that a future version of dynamic arrays works more like TABLES and can be totaled and formatted, etc.


Thanks All...I'll keep trying


BrianGGG
 
Upvote 0
Here's what I get with the array formula:

BCD
73456
74789
75101112
76323
77
78
7924

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Summary

Array Formulas
CellFormula
B79{=SUM(INDEX(B73:D76,0,{1;2;3}))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
I did. In Excel 2010, I select 3 horizontal cells and array-enter either formula (press ctrl+shift+Enter instead of just Enter). The result is 24, 26 and 30 respectively.

Apologies. I thought you were referring to a single-cell array formula (as I was in my solution), not to a multi-cell array formula.

XOR LX is expert at finding creative, albeit contorted, ways to fool Excel into delivering embedded arrays.

"Contorted"? "Fool Excel"? :)

Cheers
 
Upvote 0
Sorry if I messed this up.

I tried to select the 3 horizontal columns and enter the formula. If I try to delete one of the cells, it says that I can't change an array, so I think I succeeded. Yet:



BCD
73456
74789
75101112
76323
77
78
79242424

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Summary

Array Formulas
CellFormula
B79:D79{=SUM(INDEX(B73:D76,0,{1;2;3}))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0
Sorry for the multiple replies...

Interestingly enough, the following DOES work:



BCD
73456
74789
75101112
76323
77
78
79242630

<colgroup><col style="width: 25pxpx"><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Summary

Array Formulas
CellFormula
B79:D79{=SUM(INDEX(B73:D76,,SEQUENCE(1,3)))}

<thead>
</thead><tbody>
</tbody>
Entered with Ctrl+Shift+Enter. If entered correctly, Excel will surround with curly braces {}.
Note: Do not try and enter the {} manually yourself

<tbody>
</tbody>
 
Upvote 0

Forum statistics

Threads
1,215,111
Messages
6,123,151
Members
449,098
Latest member
Doanvanhieu

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