Trying to sum a value in column C if value in column A=x and B=y

JohnAndersen

New Member
Joined
Feb 4, 2011
Messages
10
I have a decent sized database and I am trying to sum multiple individual's yearly sales credit (current and historical). column C is the value I am trying to sum. Column A contains the last name and column B contains the year I am trying to reference. Does this make sense? Does anyone do something similiar. For reference here is my last attempt:

=IF(AND(NAME="Smith",YEAR=2010),SUM(SALES CREDIT),"YOU DID IT WRONG")

I am trying to use dynamic named ranges for this. Is that the issue?

I am a relative beginner. Thanks in advance for your help!
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.
I have a decent sized database and I am trying to sum multiple individual's yearly sales credit (current and historical). column C is the value I am trying to sum. Column A contains the last name and column B contains the year I am trying to reference. Does this make sense? Does anyone do something similiar. For reference here is my last attempt:

=IF(AND(NAME="Smith",YEAR=2010),SUM(SALES CREDIT),"YOU DID IT WRONG")

I am trying to use dynamic named ranges for this. Is that the issue?

I am a relative beginner. Thanks in advance for your help!
Looks like you want...

=SUMPRODUCT(--($A$2:$A$400="Smith"),--($B$2:$B$400=2010),$C$2:$C$400)

Adjust the ranges to suit.
 
Upvote 0
Looks like you want...

=SUMPRODUCT(--($A$2:$A$400="Smith"),--($B$2:$B$400=2010),$C$2:$C$400)

Adjust the ranges to suit.


Thanks for the info, it looks like sumproduct is the way to go. I am trying to use the formula with my currently existing named ranges that would take the please of each A B and C above :

RangeA:=OFFSET('<sheet1>'!$AI$1,1,0,COUNTA(<sheet1>!$AI:$AI),1)

RangeB:=OFFSET('<sheet1>'!$B$1,1,0,COUNTA('<sheet1>'!$B:$B),1)

RangeC:=OFFSET('<sheet1>'!$AM$1,1,0,COUNTA('<sheet1>'!$AM:$AM),1)

I was reading that each array needs to have the same dimensions. Each of these should contain the same dimensions of data, though.

I guess there must be something I am missing.
 
Upvote 0
Thanks for the info, it looks like sumproduct is the way to go. I am trying to use the formula with my currently existing named ranges that would take the please of each A B and C above :

RangeA:=OFFSET('<SHEET1>'!$AI$1,1,0,COUNTA(<SHEET1>!$AI:$AI),1)

RangeB:=OFFSET('<SHEET1>'!$B$1,1,0,COUNTA('<SHEET1>'!$B:$B),1)

RangeC:=OFFSET('<SHEET1>'!$AM$1,1,0,COUNTA('<SHEET1>'!$AM:$AM),1)

I was reading that each array needs to have the same dimensions. Each of these should contain the same dimensions of data, though.

I guess there must be something I am missing.

Why don't you have a sheet name? If that's a mistake, what would be that name?
 
Upvote 0
That's strange, I put <sheet1> in each of those formulas. In any event the sheet name in each spot would be "master list"
 
Upvote 0
That's strange, I put <SHEET1>in each of those formulas. In any event the sheet name in each spot would be "master list"

RangeA:=OFFSET('Master List<SHEET1>'!$AI$1,1,0,COUNTA('Master List<SHEET1>'<SHEET1>!$AI:$AI),1)

RangeB:=OFFSET('Master List<SHEET1><SHEET1>'!$B$1,1,0,COUNTA('Master List<SHEET1><SHEET1>'!$B:$B),1)

RangeC:=OFFSET('<SHEET1>Master List<SHEET1>'!$AM$1,1,0,COUNTA('Master List<SHEET1><SHEET1>'!$AM:$AM),1)
 
Upvote 0
RangeA:=OFFSET('Master List<SHEET1>'!$AI$1,1,0,COUNTA('Master List<SHEET1>'<SHEET1>!$AI:$AI),1)

RangeB:=OFFSET('Master List<SHEET1><SHEET1>'!$B$1,1,0,COUNTA('Master List<SHEET1><SHEET1>'!$B:$B),1)

RangeC:=OFFSET('<SHEET1>Master List<SHEET1>'!$AM$1,1,0,COUNTA('Master List<SHEET1><SHEET1>'!$AM:$AM),1)

I'm assuming that the real data starts at row 2 while row 1 houses headers...

Define VSize (from Vertical Size) as referring to:

=MATCH(9.99999999999999E+307,'Master List<SHEET1><SHEET1>'!$AM:$AM)-ROW('Master List<SHEET1><SHEET1>'!$AM$2)+1

Define RangeA as referring to:

=OFFSET('Master List<SHEET1><SHEET1>'!$AI$2,0,0,VSize)

RangeB as:

=OFFSET('Master List<SHEET1><SHEET1>'!$B$2,0,0,VSize)

and RangeC as:

=OFFSET('<SHEET1>Master List<SHEET1>'!$AM$2,0,0,VSize)

Now substituting these range names as appropriate in a SumProduct formula or any other would work as expected.
 
Upvote 0
I'm assuming that the real data starts at row 2 while row 1 houses headers...

Define VSize (from Vertical Size) as referring to:

=MATCH(9.99999999999999E+307,'Master List<SHEET1><SHEET1>'!$AM:$AM)-ROW('Master List<SHEET1><SHEET1>'!$AM$2)+1

Define RangeA as referring to:

=OFFSET('Master List<SHEET1><SHEET1>'!$AI$2,0,0,VSize)

RangeB as:

=OFFSET('Master List<SHEET1><SHEET1>'!$B$2,0,0,VSize)

and RangeC as:

=OFFSET('<SHEET1>Master List<SHEET1>'!$AM$2,0,0,VSize)

Now substituting these range names as appropriate in a SumProduct formula or any other would work as expected.

This works perfectly. Thank you so much.
 
Upvote 0

Forum statistics

Threads
1,224,587
Messages
6,179,733
Members
452,939
Latest member
WCrawford

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