Excel Formula: Match 2 Criteria in Column & Sum up all Rows

Apple1

Board Regular
Joined
Jan 18, 2015
Messages
121
Hi

I want an Excel formula that will allow
1) match the Year in Row1, and match the Sales or Profit in Row 2
2) sum all the rows in the matched column

EG, I want Year=2001 & Sales, so the formula will sum = 8559 + 4560 +1520 +1563

Thank you!


2001
2001
2002
2002
Sales
Profit
Sales
Profit
James
1000
690
8559
1895
Peter
2000
756
4560
1596
Tom
3000
56
1520
3698
Edwin
4000
56
1563
4563

<tbody>
</tbody>
 
My bad. It should have been:

=SUM(INDEX($B$3:$E$6,0,MATCH($H1,IF($B$2:$E$2=$I1,$B$1:$E$1),0)))

which needs to be confirmed with control+shift+enter.

Hi

Thanks for the reply. But I prefer to use sumproduct. But when I modified Cell G1 = CY2017-Q1
and the formula
G2=SUMPRODUCT(($B$1:$E$1=mid(G1,3,4))*($B$2:$E$2=G2)*($B$3:$E$6))

It doesn't work.

How to solve this?

Thanks!
 
Upvote 0

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Hi

Thanks for the reply. But I prefer to use sumproduct. But when I modified Cell G1 = CY2017-Q1
and the formula
G2=SUMPRODUCT(($B$1:$E$1=mid(G1,3,4))*($B$2:$E$2=G2)*($B$3:$E$6))

It doesn't work.

How to solve this?

Thanks!

Using the same sample as before...

H1: 2002
I1: Sales

In J1 enter:

=SUMPRODUCT($B$3:$E$6*(($B$1:$E$1=$H1)*($B$2:$E$2=I1)))

or control+shift+enter, not just enter:

=SUM(INDEX($B$3:$E$6,0,MATCH($H1,IF($B$2:$E$2=$I1,$B$1:$E$1),0)))
 
Upvote 0
Using the same sample as before...

H1: 2002
I1: Sales

In J1 enter:

=SUMPRODUCT($B$3:$E$6*(($B$1:$E$1=$H1)*($B$2:$E$2=I1)))

or control+shift+enter, not just enter:

=SUM(INDEX($B$3:$E$6,0,MATCH($H1,IF($B$2:$E$2=$I1,$B$1:$E$1),0)))

Hi

You are missing the point. I want to extract text in the criteria.
For Eg,
H1: CY2002-Q1

so the formula should be

=SUMPRODUCT($B$3:$E$6*(($B$1:$E$1=mid($H1,3,4))*($B$2:$E$2=I1)))

But it doesn't work.
 
Upvote 0
Hi

You are missing the point. I want to extract text in the criteria.
For Eg,
H1: CY2002-Q1

so the formula should be

=SUMPRODUCT($B$3:$E$6*(($B$1:$E$1=mid($H1,3,4))*($B$2:$E$2=I1)))

But it doesn't work.

I advise you to post a sample where CY2002-Q1 occurs...
 
Upvote 0

Forum statistics

Threads
1,216,128
Messages
6,129,033
Members
449,482
Latest member
al mugheen

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