Sumif then Sumproduct in One Formula

chad13

Board Regular
Joined
Oct 14, 2002
Messages
105
I have a table (below) that I want to add a total at the bottom of the column D to represent the total of RED and the total of BLUE based on the following formula.
For red: sum of ((Rate 1 + Rate 2)*hours)*Red Factor
For blue: sum of ((Rate 1 + Rate 2)*hours)*Blue Factor
I think it would be a sumproduct and a sumif-type formula possibly. i.e. sumif columns C & D then multiply the result by Column B then that total by the Factor.

Red Factor 2.02
Blue Factor 1.50

Column A Column B Column C Column D (Example of the math for each row that I would like to total at the bottom of column D based on blue or red)
Hours Rate 1 Rate 2
RED 25.00 $8.00 $2.23 ((8.00+2.23)*25)*2.02
BLUE 21.00 $7.23 $1.74 ((7.23+1.74)*21)*1.50
BLUE 19.00 $6.15 $2.54 ((6.15+2.54)*19)*1.50
BLUE 17.00 $9.54 $1.65 ((9.54+1.65)*17)*1.50
RED 22.00 $7.56 $1.42 ((7.56+1.42)*22)*2.02
RED 23.00 $8.41 $2.17 ((8.41+2.17)*23)*2.02

The results would be as follows:
RED: $1,407.23
BLUE: $815.57

Note that I cannot add another column.

Thanks!

Chad
 

Excel Facts

How to change case of text in Excel?
Use =UPPER() for upper case, =LOWER() for lower case, and =PROPER() for proper case. PROPER won't capitalize second c in Mccartney
Hi!

Try this in I2 and copy down:

=SUMPRODUCT(--(A$2:A$7=H2),D$2:D$7+C$2:C$7,INT(B$2:B$7))*G2

Or

=SUMPRODUCT(--(A$2:A$7=H2),D$2:D$7+C$2:C$7,B$2:B$7)*G2

ABCDEFGHIJ
1HoursRate1Rate2Result
2RED25,008,002,23Red Factor2,02RED1407,23
3BLUE21,007,231,74Blue Factor 1,50BLUE815,57
4BLUE19,006,152,54
5BLUE17,009,541,65
6RED22,007,561,42
7RED23,008,412,17
8
*******************************************************

<tbody>
</tbody>


Markmzz
 
Last edited:
Upvote 0
Row\Col
A​
B​
C​
D​
1​
RED
25​
$8.00​
$2.23​
2​
BLUE
21​
$7.23​
$1.74​
3​
BLUE
19​
$6.15​
$2.54​
4​
BLUE
17​
$9.54​
$1.65​
5​
RED
22​
$7.56​
$1.42​
6​
RED
23​
$8.41​
$2.17​
7​
8​
9​
10​
11​
RED
$1,407.23​
12​
BLUE
$815.57​

In B11 enter and copy down to B12...

=SUMPRODUCT(--($A$1:$A$6=$A11),$B$1:$B$6,($C$1:$C$6+$D$1:$D$6)*IF($A11="red",2.02,IF($A11="blue",1.5,0)))
 
Upvote 0
Thank you. Both of these work nicely.
But, because I have different sections that I add up across a large range, there are text items in some of these ranges. Therefore, I get an error. Can the formula be modified to not error out?
 
Upvote 0
Thank you. Both of these work nicely.
But, because I have different sections that I add up across a large range, there are text items in some of these ranges. Therefore, I get an error. Can the formula be modified to not error out?

Try this:

Use Ctrl+Shift+Enter to enter the formula

=SUM((A$2:A$7=H2)*IF(ISNUMBER((D$2:D$7+C$2:C$7)*(B$2:B$7)),(D$2:D$7+C$2:C$7)*B$2:B$7))*G2

Or

=SUM((A$2:A$7=H2)*IFERROR((D$2:D$7+C$2:C$7)*B$2:B$7,0))*G2

Markmzz
 
Last edited:
Upvote 0
In addition, how can I modify the formula to remove the Blue/Red criteria? i.e. calculate that formula for all of the rows not basing on the value of column A?

I thought that just removing the "=H2" from the formula would do it, but that didn't work.
 
Upvote 0
In addition, how can I modify the formula to remove the Blue/Red criteria? i.e. calculate that formula for all of the rows not basing on the value of column A?

I thought that just removing the "=H2" from the formula would do it, but that didn't work.

Try this:

Use Ctrl+Shift+Enter to enter the formula

=SUM(IFERROR(IF(A$2:A$7="RED",$G$2,IF(A$2:A$7="BLUE",$G$3))*(D$2:D$7+C$2:C$7)*B$2:B$7,0))

Markmzz
 
Upvote 0

Forum statistics

Threads
1,215,054
Messages
6,122,897
Members
449,097
Latest member
dbomb1414

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