Why is the SUM, INDEX, MATCH function not working for one, whilst it works for the other

ihateexcell

New Member
Joined
Aug 8, 2023
Messages
5
Office Version
  1. 365
Platform
  1. Windows
I am trying to understand why is it if I use the following
Code:
=SUM(N3:INDEX(N3:N11,MATCH(TRUE,(M3:M11=""),0)))
, it successfully sums as expected once it hits an empty cell the next row but...

if I change it to
Code:
=SUM(N3:INDEX(N3:N11,MATCH(1,(M3:M11),0)))
, it only adds the first value in N column even though M4 and M5 matches the lookup value too
Index is column M while Total is column N

1692242826115.png
 

Excel Facts

Show numbers in thousands?
Use a custom number format of #,##0,K. Each comma after the final 0 will divide the displayed number by another thousand
Please note that the MATCH function returns the first found position and will disregard subsequent values.
 
Upvote 0
Also note that, with your formula, if there is a value in N6, it will be added in your result even if M6 is empty as INDEX(N3:N11,MATCH(TRUE,(M3:M11=""),0)) returns a reference to N6
 
Upvote 0
it only adds the first value in N column even though M4 and M5 matches the lookup value too
@bebo021999 has explained why your second formula only summed the one value, but to get the sum you seem to be trying for, you could use
Excel Formula:
=SUMIFS(N3:N11,M3:M11,1)
 
Upvote 0
Also note that, with your formula, if there is a value in N6, it will be added in your result even if M6 is empty as INDEX(N3:N11,MATCH(TRUE,(M3:M11=""),0)) returns a reference to N6
Hmm it doesn't though, it'll only be added if M5 has a value, because it's referencing column for an empty cell, once it hits one it stops summing

@bebo021999 has explained why your second formula only summed the one value, but to get the sum you seem to be trying for, you could use
Excel Formula:
=SUMIFS(N3:N11,M3:M11,1)
Thanks for the alternative, I was figuring out a way to just fill the first cell of Index/M column for each entry e.g. 1 for entry #1, 2 for entry #2 etc but I guess this/the first code will have to do
 
Upvote 0
Upvote 0
I think the OP wants it to sum to the value in column N if column M on the previous row has a value
Yes, I know what the OP wants. However, @arthurbr pointed out that the very first formula posted (& noted as returning the correct result) would actually fail if there was a value in column N next to the first blank in column M.
I read post #5 as the OP disagreeing with that statement in post #3 so I posted an example to support it. :)
 
Upvote 0
I think the OP wants it to sum to the value in column N if column M on the previous row has a value (although not worded well if that is the case in post number 1)
Actually what I would like to do is to sum N3-N6 without having to fill M4-6 with any values thus, I was trying with INDEX MATCH but wasn't able to get it to work, so in the meantime I'll take @Peter_SSs's SUMIF suggestion as workaround

1692284000480.png

Yes it does ..

23 08 17.xlsm
LMN
1
2
3100612
412
512
61000
721600
Sample
Cell Formulas
RangeFormula
L3L3=SUM(N3:INDEX(N3:N11,MATCH(TRUE,(M3:M11=""),0)))
My bad there, apparently couldn't count as well; thanks @arthurbr
 
Upvote 0
Actually what I would like to do is to sum N3-N6 without having to fill M4-6 with any values
What about this then?

23 08 18.xlsm
MNOPQ
1
2IndexTotalIndexSum
31100011003
4121600
51
61
721600
8
9
10
11
Sum by Index
Cell Formulas
RangeFormula
Q3:Q4Q3=LET(M,M$3:M$11,N,N$3:N$11,fr,MATCH(P3,M,0),lr,IFNA(MATCH(TRUE,INDEX(M,fr+1):M$11<>"",0),ROWS(N)),SUM(INDEX(N,fr):INDEX(N,lr)))
 
Upvote 0

Forum statistics

Threads
1,223,922
Messages
6,175,384
Members
452,639
Latest member
RMH2024

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