Sumproduct / Sumifs

Tikey

Board Regular
Joined
Jan 30, 2014
Messages
148
Office Version
  1. 2021
Platform
  1. Windows
Hi

I am trying to sum a number of values in 3 columns, if the year from a date in another column is correct and if the values in another column contain an x, which could be in any position in the cells. My spreadsheet could contain several thousand rows, but I have included a small example. I am also wishing to avoid using a helper column.


A​
B​
C​
D​
E​
1​
3​
09/07/2020​
64XBC10
2​
2​
09/07/2020​
64XBC10
3​
6​
09/07/2020​
64XBC10
4​
16​
4​
09/07/2022​
64FX12
5​
3​
2​
09/07/2022​
64XA12
6​
1​
4​
10/07/2022​
64FGT12
7​
1​
11/07/2021​
64FX12
8​
2​
13/07/2021​
64XFC15
9​
3​
1​
1​
13/07/2021​
64XFC15
10​
1​
16/07/2021​
64XFC15

So, if I wanted to sum the values in columns A,B,C if the year was 2022 and the values in column E contained an x, I would expect the result to be 25.

I have managed to do this with SUMIFS using the following formula, but it will only sum a single column, if I try to sum all 3 I get a #Value! error.
=SUMIFS(A2:A11,D2:D11,">="&DATE(2022,1,1),$D2:$D11,"<="&DATE(2022,12,31),E2:E11,"*x*")
I have tried to use SUMPRODUCT without success, but believe you cannot use wildcards with this.

Can anyone offer a solution please.

 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.
how about: (this gives sum for each row that meets criteria, next message give aggregate)
Mr Excel Questions 9.xlsm
ABCDEFG
1ABCDE2022
213002020-07-0264XBC100
322002020-07-0264XBC100
436002020-07-0264XBC100
5416402022-07-0264FX1220
653022022-07-0264XA125
761402022-07-0264FGT120
871002021-07-0264FX120
982002021-07-0264XFC150
1093112021-07-0264XFC150
11101002021-07-0264XFC150
Sheet5
Cell Formulas
RangeFormula
G2:G11G2=(--(G1=YEAR(E2:E11)))* (ISNUMBER(FIND("X",F2:F11)))*(B2:B11+C2:C11+D2:D11)
Dynamic array formulas.
 
Upvote 0
Excel Formula:
=SUM((--(G1=YEAR(E2:E11)))*(ISNUMBER(FIND("X",F2:F11)))*(B2:B11+C2:C11+D2:D11))
 
Upvote 0
Solution
how about
=SUM(FILTER($A$2:C$33,(YEAR($D$2:$D$33)=2022)*(ISNUMBER(SEARCH("X",$E$2:$E$33,1)))))

Book7
ABCDEFG
1
237/9/2064XBC1025
327/9/2064XBC10
467/9/2064XBC10
51647/10/2264FX12
6327/11/22aaaX
7147/12/2264FGT12
811/1/2364FX12
921/2/2364XFC15
103111/3/2364XFC15
1111/4/2364XFC15
Sheet1
Cell Formulas
RangeFormula
G2G2=SUM(FILTER($A$2:C$32,(YEAR($D$2:$D$32)=2022)*(ISNUMBER(SEARCH("X",$E$2:$E$32,1)))))
 
Upvote 0
Another way:
Book1
ABCDEFG
139/7/202064XBC1025
229/7/202064XBC10
369/7/202064XBC10
41649/7/202264FX12
5329/7/202264XA12
61410/7/202264FGT12
7111/7/202164FX12
827/13/202164XFC15
93117/13/202164XFC15
1017/16/202164XFC15
Sheet1
Cell Formulas
RangeFormula
G1G1=SUM(IF((YEAR(D1:D10)=2022)*(ISNUMBER(SEARCH("x",E1:E10))),A1:C10,0))
 
Upvote 0
Excel Formula:
=SUM((--(G1=YEAR(E2:E11)))*(ISNUMBER(FIND("X",F2:F11)))*(B2:B11+C2:C11+D2:D11))
Thanks very much, that works great. Rather than using refs for the 3 seperate columns, could I just use b2:d11 ?
 
Upvote 0
I don't think so. You would be multiplying some items by zero making the value zero. But you can try.
 
Upvote 0
I don't think so. You would be multiplying some items by zero making the value zero. But you can try.
I best not in case I get a incorrect answer and I don't realise. Thanks very much for your help.
 
Upvote 0

Forum statistics

Threads
1,214,948
Messages
6,122,420
Members
449,083
Latest member
Ava19

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