Sumproduct based on text values

mountainman88

Board Regular
Joined
Jun 22, 2019
Messages
109
Office Version
  1. 2016
Platform
  1. Windows
I have been able to SUMPRODUCT a total amount in cell E4 using text entered into cells F1 and F2 to create conditions. How do I modify the formula so that if F1 contains the text "Total", that the conditions for the SUMPRODUCT are "Yes" AND "No", and if cell F2 contains the text "Total" the conditions for the SUMPRODUCT are "COS" AND "SGA" AND "Revenue"?

Thank


ABCDEF
1
IT?
PLAMTIT?Yes/No/Total
2YesCOS50000PLCOS/SGA/Revenue/Total
3YesSGA10000
4NoSGA20000Result:=SUMPRODUCT((C2:C5),--(A2:A5=F1),--(B2:B5=F2))
5YesRevenue40000
 

Excel Facts

Get help while writing formula
Click the italics "fx" icon to the left of the formula bar to open the Functions Arguments dialog. Help is displayed for each argument.
How about this

Book1
ABCDEFG
1IT?PLAMTIT?Total
2YesCOS50000PLTotal
3YesSGA10000
4NoSGA20000Result:120000
5YesRevenue40000
6
7
Sheet1
Cell Formulas
RangeFormula
E4E4=SUMPRODUCT(C2:C5,IF(F1="Total",(C2:C5)^0,--(A2:A5=F1)),IF(F2="Total",(C2:C5)^0,--(B2:B5=F2)))
 
Upvote 0
How about this

Book1
ABCDEFG
1IT?PLAMTIT?Total
2YesCOS50000PLTotal
3YesSGA10000
4NoSGA20000Result:120000
5YesRevenue40000
6
7
Sheet1
Cell Formulas
RangeFormula
E4E4=SUMPRODUCT(C2:C5,IF(F1="Total",(C2:C5)^0,--(A2:A5=F1)),IF(F2="Total",(C2:C5)^0,--(B2:B5=F2)))
Did this work for you? It doesn't for me I tried something similar also before but I dont think SUMPRODUCT likes that nested IF function.

Also using the ^0 would need there to be a number in every cell in the column which may not be the case, ie some may be blank ( I should have made this clear in the example)

Thanks
 
Upvote 0
Book1
ABCDEF
1IT?PLAMTIT?Yes
2YesCOS50000PLSGA
3YesSGA
4NoSGA20000Result:0
5YesRevenue40000
6
Sheet1
Cell Formulas
RangeFormula
E4E4=SUMPRODUCT(C2:C5,IF(F1="Total",((C2:C5)+1)^0,--(A2:A5=F1)),IF(F2="Total",((C2:C5)+1)^0,--(B2:B5=F2)))


Yes it is Working For me as stated in the Example. If there is Blank I have Just Added 1 to the Range so that it turns into number and then used to the power ^0 which will convert all the number into 1 if there is Total.
 
Upvote 0
Book1
ABCDEF
1IT?PLAMTIT?Yes
2YesCOS50000PLSGA
3YesSGA
4NoSGA20000Result:0
5YesRevenue40000
6
Sheet1
Cell Formulas
RangeFormula
E4E4=SUMPRODUCT(C2:C5,IF(F1="Total",((C2:C5)+1)^0,--(A2:A5=F1)),IF(F2="Total",((C2:C5)+1)^0,--(B2:B5=F2)))


Yes it is Working For me as stated in the Example. If there is Blank I have Just Added 1 to the Range so that it turns into number and then used to the power ^0 which will convert all the number into 1 if there is Total.
I am getting #Value when I copy your exact formula
excel.JPG
 
Upvote 0
ng the ^0 would need there to be a number in every cell in the column which may not be the case, ie some may be blank ( I should have made this clear in the example)

For this see Post 4
=SUMPRODUCT(C2:C5,IF(F1="Total",((C2:C5)+1)^0,--(A2:A5=F1)),IF(F2="Total",((C2:C5)+1)^0,--(B2:B5=F2)))
 
Upvote 0
Enter with Control+Shift+Enter and Not Just Enter
ah, didnt see the squiggly lines in your example,works now.

Im concerned this may be very slow with lots of array functions (the real sheet is far bigger) but i will try and see.

thanks for your help
 
Upvote 0
Enter with Control+Shift+Enter and Not Just Enter
Here is my more complicated formula, I am using Ctrl-Shift-enter but no luck, is it because im using offsheet ranges? or is the formula wrong?

=SUMPRODUCT(('07.21'!AF$1:AF$2000),--('07.21'!$A$1:$A$2000=$B7),--('07.21'!$BO$1:$BO$2000=$D7),IF($C$2="Total",(('07.21'!AF$1:AF$2000)+1)^0,--('07.21'!$BP$1:$BP$2000=$C$2)),IF($C$4="Total",(('07.21'!AF$1:AF$2000)+1)^0,--('07.21'!$I$1:$I$2000=$C$4)))

thanks
 
Upvote 0

Forum statistics

Threads
1,214,430
Messages
6,119,453
Members
448,898
Latest member
drewmorgan128

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