Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Conditional sum, with 2 conditions 2

Status
Not open for further replies.

Melko

Civil/Environmental
Mar 25, 2002
53
I have to sum a column data when, not just one condition is met, but 2.

In my case the year and the month of a date must equal to what I want.

Is that possible?
 
Replies continue below

Recommended for you

Hello,

Try this formula

=SUMPRODUCT(--(A1:A5="Jan"),--(B1:B5=2004),(C1:C5))

A B C
1 Jan 2004 1
2 Feb 2004 2
3 Jan 2004 3
4 Apr 2004 4
5 May 2004 5

Answer will be 4



----------------------------------
Hope this helps.
----------------------------------

maybe only a drafter
but the best user at this company!
 
I found a good solution...

Since month never overtook 12 and day never overtook 31 it is enough strip all the date in a single number, like this:

E.G.
13/06/2004 is the date (cell a1)
with the formula
=year(a1)*10000+month(a1)*100+day(a1)
become
20040613 easily usable for conditions :)

in my case I needed only the month so it'll become
=year(a1)*100+month(a1)
for 200406
 
Or you can convert the date to a number (ie. 2 April 04 = 38022). Therefore you only need one condition.
 
Hi Melko,
Probably you already have a solution but i found a general solution for such problems in the website of j-walk, "Excel Developer tip". The formula we use for conditional summing is SUMIF. But for multiple criteria in different fields, the SUMIF function doesn't work. However, you can use an array formula. Remember, When you an array formula, press ctrl+Shift+Enter after you write it.

For example
Sum of Sales where Month="Jan" AND Region="North"

=SUM((A2:A10="Jan")*(B2:B10="North")*C2:C10)

Enjoy!
[2thumbsup]

 
Array formulas? What is that?
Wow, I have to try...
 
An array is a group (a list or a table) of data such as matrix. In EXCEL you can perform certain matrix calculations with array formula. Just see help for matrix calculations.
 
Melko,

I think you have nailed it with your first solution above, but otherwise you can combine logical IF and AND functions, i.e.

=IF(AND(condition1,condition2)=TRUE,SUM(C6:C15),"")

for example.
 
JohnGP,

I am afraid that is do not work that way.
I mean, if both condition are true I'll just have the sum of ALL data in the c6:c15 and not only the ones that respect the condition and if both condition are not meet I'll just hve nothing.

Am I wrong?
 
Oops, sorry Melko, my perception of the issue was obviously flawed.....I'll dig myself another hole.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor