#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 187
Default SUMIF vs SUMPRODUCT

The following returns 223,559.29:

=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))

The following returns 0:

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)

I would expect these two formulas to return the same value. What am I
doing wrong with the SUMIF formula (the value returned by SUMPRODUCT
appears to be correct.)

Thanks.

Dave
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,389
Default SUMIF vs SUMPRODUCT

Sumif does not support formulas for its criteria.

Regards,
Fred.

"Dave F" wrote in message
...
The following returns 223,559.29:

=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))

The following returns 0:

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)

I would expect these two formulas to return the same value. What am I
doing wrong with the SUMIF formula (the value returned by SUMPRODUCT
appears to be correct.)

Thanks.

Dave


  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15,768
Default SUMIF vs SUMPRODUCT

SUMIF can't "manipulate" an *array* in any of it's agruments.

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)


In the formula you're attempting to manipulate the array D2:D456
using --(RIGHT(D2:D456,5)="37057").

In this case, --(RIGHT(D2:D456,5)="37057")

Evaluates only --(RIGHT(D2,5)="37057")

Which further evaluates to either 1 or 0 depending on what's in D2 so that
the criteria is actually either a 1 or 0:

=SUMIF(D2:D456,1,Q2:Q456)
=SUMIF(D2:D456,0,Q2:Q456)


--
Biff
Microsoft Excel MVP


"Fred Smith" wrote in message
...
Sumif does not support formulas for its criteria.

Regards,
Fred.

"Dave F" wrote in message
...
The following returns 223,559.29:

=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))

The following returns 0:

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)

I would expect these two formulas to return the same value. What am I
doing wrong with the SUMIF formula (the value returned by SUMPRODUCT
appears to be correct.)

Thanks.

Dave




  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 3,572
Default SUMIF vs SUMPRODUCT

<<<"Sumif does not support formulas for its criteria."

Not really true!

If the formula returns a viable criteria, it will work within Sumif().

For example:

=Sumif(A1:A10,Sum(B2:B4),C1:C10)

Will work, where the sum formula equals a value in A1 to A10.

Or, if greater then the sum total:

=Sumif(A1:A10,""&Sum(B2:B4),C1:C10)
--
Regards,

RD

---------------------------------------------------------------------------
Please keep all correspondence within the NewsGroup, so all may benefit !
---------------------------------------------------------------------------

"Fred Smith" wrote in message
...
Sumif does not support formulas for its criteria.

Regards,
Fred.

"Dave F" wrote in message
...
The following returns 223,559.29:

=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))

The following returns 0:

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)

I would expect these two formulas to return the same value. What am I
doing wrong with the SUMIF formula (the value returned by SUMPRODUCT
appears to be correct.)

Thanks.

Dave




  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 8,856
Default SUMIF vs SUMPRODUCT

Try it this way:

=SUM(IF(RIGHT(D2:D456,5)="37057",Q2:Q456))

This is an array formula, which means that once you have typed it in (or
subsequently edit it) you must use Ctrl-Shift-Enter (CSE) to commit it,
rather than the usual <Enter. If you do this correctly, then Excel will
wrap curly braces { } around the formula when viewed in the formula bar -
you must not type these yourself.

Note the similarity with the SUMPRODUCT formula, but with that you do not
need to use CSE.

Hope this helps.

Pete

"Dave F" wrote in message
...
The following returns 223,559.29:

=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))

The following returns 0:

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)

I would expect these two formulas to return the same value. What am I
doing wrong with the SUMIF formula (the value returned by SUMPRODUCT
appears to be correct.)

Thanks.

Dave





  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 4,393
Default SUMIF vs SUMPRODUCT

Dave,
Should that be
=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))
or
=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"), Q2:Q456)
The double negation is not needed on the Q range if they hold numbers
We use that to convert False/True to 0/1
best wishes
--
Bernard Liengme
Microsoft Excel MVP
http://people.stfx.ca/bliengme


"Dave F" < wrote in message
...
The following returns 223,559.29:

=SUMPRODUCT(--(RIGHT(D2:D456,5)="37057"),--(Q2:Q456))

The following returns 0:

=SUMIF(D2:D456,--(RIGHT(D2:D456,5)="37057"),Q2:Q456)

I would expect these two formulas to return the same value. What am I
doing wrong with the SUMIF formula (the value returned by SUMPRODUCT
appears to be correct.)

Thanks.

Dave


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Sumif or Sumproduct? Helpless in Colorado Excel Discussion (Misc queries) 12 April 16th 08 01:55 PM
sumproduct? sumif(sumproduct)? David Excel Worksheet Functions 3 July 13th 07 07:06 PM
SUMPRODUCT or SUMIF Serge Excel Discussion (Misc queries) 17 April 10th 06 11:50 PM
SUMPRODUCT or SUMIF nfbelo Excel Worksheet Functions 2 May 24th 05 07:18 PM
SUMPRODUCT or SUMIF or ... nfbelo Excel Worksheet Functions 4 May 24th 05 06:34 PM


All times are GMT +1. The time now is 01:51 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"