If... Sum If

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

If... Sum If

Post by VegasNath »

I am trying to sum column P if column B = x and column M <> "Accrual"

=IF(Download!$M:$M<>"Accrual",SUMIF(Download!$B:$B,"x",Download!$P:$P),0)

Where am I going wrong?
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: If... Sum If

Post by HansV »

In Excel 2007 and later, you can use the SUMIFS function:

=SUMIFS(Download!$P:$P,Download!$B:$B,"x",Download!$M:$M,"<>Accrual")

In all versions:

=SUMPRODUCT(Download!$P:$P*(Download!$B:$B="x")*(Download!$M:$M<>"Accrual"))
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: If... Sum If

Post by VegasNath »

Hans, I get #NUM! (in the SUMPRODUCT version)
Last edited by VegasNath on 27 May 2010, 20:27, edited 1 time in total.
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: If... Sum If

Post by HansV »

Using the first formula or the second one? (It helps me to help you if you're specific)
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: If... Sum If

Post by VegasNath »

Sorry, see edit.
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: If... Sum If

Post by HansV »

What happens if you use limited ranges, e.g.

=SUMPRODUCT(Download!$P1:$P1000*(Download!$B1:$B1000="x")*(Download!$M1:$M1000<>"Accrual"))
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: If... Sum If

Post by VegasNath »

Thanks Hans, got it.

Also, this works, but how can I sum <>"Accrual"

=SUMIF(Download!$M:$M,"Accrual",Download!$P:$P)-SUM(G8:G30)
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: If... Sum If

Post by HansV »

=SUMIF(Download!$M:$M,"<>Accrual",Download!$P:$P)-SUM(G8:G30)
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: If... Sum If

Post by VegasNath »

That does not work. I need to sum everything where accrual is not in column M. Something like =SUMIF(NOT(..... but I can't get the syntax correct.
:wales: Nathan :uk:
There's no place like home.....

User avatar
HansV
Administrator
Posts: 78493
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: If... Sum If

Post by HansV »

It works in Excel 2007. But try this, in analogy to the earlier formula:

=SUMPRODUCT((Download!$M$1:$M$1000<>"Accrual")*Download!$P$1:$P$1000)-SUM(G8:G30)
Best wishes,
Hans

User avatar
VegasNath
5StarLounger
Posts: 1185
Joined: 24 Jan 2010, 12:02
Location: Wales, UK.

Re: If... Sum If

Post by VegasNath »

Sorry Hans, your first attempt was correct, my data was distorted. :cheers:
:wales: Nathan :uk:
There's no place like home.....