Calculate the first four cells based on condition

addy_89

New Member
Joined
Jul 9, 2014
Messages
21
ABCD
x16-03-20142
x16-03-20143
x16-03-20144
x16-03-20145
x16-03-20146
x17-03-20147
x17-03-20148
x17-03-20149
x17-03-201410
y17-03-20141

<colgroup><col><col><col span="2"></colgroup><tbody>
</tbody>


In the above example, i want to sum the first four cells where data in column a and column b is matching and after summing the first four values, i want excel to sum the rest of the values for the matching data in column in a and b which not necessary would be 4, but will be less. I have the written the array formula for this using count if and sumifs but that is giving me the sum of total values.

{=IF(COUNTIFS($A$2:$A3,A3,$B$2:$B3,B3)>1,"",SUMIFS(C:C,A:A,A3,B:B,B3))}

Is it possible? Please help, i'm stuck :(
 
Not sure why I thought that would work, definitely not one of my better ideas.

Based on your example being in columns A:F

=IF(ISNUMBER(E2),SUM(D2:INDEX(D2:D5,MATCH(40000,SUMIFS(OFFSET(C2,,,{1,2,3,4}),OFFSET(A2,,,{1,2,3,4}),A2,OFFSET(B2,,,{1,2,3,4}),B2)))),"")

I haven't tested this, you might need to confirm it as an array for it to work.
 
Upvote 0

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Not sure why I thought that would work, definitely not one of my better ideas.

Based on your example being in columns A:F

=IF(ISNUMBER(E2),SUM(D2:INDEX(D2:D5,MATCH(40000,SUMIFS(OFFSET(C2,,,{1,2,3,4}),OFFSET(A2,,,{1,2,3,4}),A2,OFFSET(B2,,,{1,2,3,4}),B2)))),"")

I haven't tested this, you might need to confirm it as an array for it to work.

Still not working, it is giving the sum of first 4 values of column D in F :(
 
Upvote 0
Check your data then, I've just tried it with your most recent example and it works perfectly.
 
Upvote 0

Forum statistics

Threads
1,216,074
Messages
6,128,654
Members
449,462
Latest member
Chislobog

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