Thanks Thanks:  0
Likes Likes:  0
Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: Can an array formula reliably do this kind of totaling?

  1. #1
    Board Regular
    Join Date
    Apr 2002
    Location
    Campbell-Ewald
    Posts
    56
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Can an array formula reliably do this kind of totaling?

    I want to sum (by month) sales by person and multiply by the price to get total sales by month.

    I thought something like {=SUM(SUM(B5:E12)*G5:G12)} or just plain {=SUM(B5:E12)*G5:G12} would work, but it doesn't, as you can see in the cell identified as "Wrong". The cell marked "Right" is a simple sum of the extended products above it--I added the sales in weeks 1 thru 4 then multiplied the total by the price for each row. Is there an array formula or some other approach that won't involve extra/hidden rows to accomplish the task? It needs to span blank rows and text without blowing up. In a test, I essentially created the Red Team block and was able to get the correct answer. However, it may have been dumb luck--once I edited or added to it so that it was more realistic like what I've shown here it quit working. I'm trying to avoid a normal formula like =sum(B5:E5)*G5+sum(B6:E6)* G6+.... as there are quite a few rows an this becomes immediately tedious. Of course, if you have some other slick way of doing this, I'd be happy to see that too!

    Excel 2010
    ABCDEFGHI
    1Sales
    2Jan   Price
    3wk1wk2wk3wk4JanExt Jan
    4Red Team
    5Joe1111520
    6Mary2929244
    7Fred5544590
    8
    9Blue Team0
    10Jane1233654
    11Marge5633351
    12Kevin89335115
    13
    142418<< WrongRight>>374

    Sheet1




  2. #2
    Board Regular
    Join Date
    Mar 2002
    Location
    NY
    Posts
    1,056
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    =SUM(B5:E12*G5:G12)
    (CSE, of course)

  3. #3
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    33,909
    Post Thanks / Like
    Mentioned
    71 Post(s)
    Tagged
    28 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Quote Originally Posted by BobUmlas View Post
    =SUM(B5:E12*G5:G12)
    (CSE, of course)
    Instead of SUM committed with CSE, why not just use SUMPRODUCT?

    =SUMPRODUCT(B5:E11*G5:G11)
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  4. #4
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    84,915
    Post Thanks / Like
    Mentioned
    43 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Try the SumProduct with its native syntax:

    =SUMPRODUCT(B5:E11,G5:G11)

    as it's devised exactly for this, that is, for multiplying a set of numerical terms.
    Assuming too much and qualifying too much are two faces of the same problem.

  5. #5
    MrExcel MVP Rick Rothstein's Avatar
    Join Date
    Apr 2011
    Location
    New Jersey, USA
    Posts
    33,909
    Post Thanks / Like
    Mentioned
    71 Post(s)
    Tagged
    28 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Quote Originally Posted by Aladin Akyurek View Post
    Try the SumProduct with its native syntax:

    =SUMPRODUCT(B5:E11,G5:G11)

    as it's devised exactly for this, that is, for multiplying a set of numerical terms.
    Good point!
    Rick's "mini" blog... http://www.excelfox.com/forum/f22/
    .
    Want to post a small screen shot? See Part B here.

  6. #6
    Board Regular
    Join Date
    Apr 2002
    Location
    Campbell-Ewald
    Posts
    56
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Excellent--didn't realize excel do the 'right' thing when multiplying inside sumproduct--I thought the ranges had to be the same size. BTW, =SUMPRODUCT(B5:E11*G5:G11) works, the 'native syntax' =SUMPRODUCT(B5:E11,G5:G11) does not--it generates an error. But it doesn't need to be CSE.

  7. #7
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    84,915
    Post Thanks / Like
    Mentioned
    43 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Quote Originally Posted by dcoons View Post
    Excellent--didn't realize excel do the 'right' thing when multiplying inside sumproduct--I thought the ranges had to be the same size. BTW, =SUMPRODUCT(B5:E11*G5:G11) works, the 'native syntax' =SUMPRODUCT(B5:E11,G5:G11) does not--it generates an error. But it doesn't need to be CSE.
    =SUMPRODUCT(B5:E11,G5:G11)

    does work, provided that B5:E11 and G5:G11 consist of true numbers. If you are on a non-American system, try:

    =SUMPRODUCT(B5:E11;G5:G11)
    Assuming too much and qualifying too much are two faces of the same problem.

  8. #8
    MrExcel MVP
    Moderator
    Scott Huish's Avatar
    Join Date
    Mar 2004
    Location
    Oregon
    Posts
    19,693
    Post Thanks / Like
    Mentioned
    5 Post(s)
    Tagged
    3 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Aladin, that will give you a #VALUE! error as the ranges are not the same size.

    Sheet1

     BCDEFGHI
    520304050 1 #VALUE!
    624364860 2  
    728425670 3  
    832486480 4  
    936547290 5  
    10406080100 6  
    11446688110 7  

    Spreadsheet Formulas
    CellFormula
    I5=SUMPRODUCT(B5:E11,G5:G11)


    Excel tables to the web >>
    Office 2010/365

  9. #9
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    84,915
    Post Thanks / Like
    Mentioned
    43 Post(s)
    Tagged
    8 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    Quote Originally Posted by Scott Huish View Post
    Aladin, that will give you a #VALUE! error as the ranges are not the same size.
    ...
    My bad. I kept reading B5:B11 while writing down B5:E11. My concern clearly does not apply. One of Sum or SumProduct with the * operator is the choice. If the ranges involved do house formula blanks or other text:

    =SUM(IF(ISNUMBER(1/(B1:E11*G1:G11)),B1:E11*G1:G11))

    confirmed with control+shift+enter, not just enter, would be the way out. The foregoing would behave like the native SumProduct with appropriate ranges.
    Assuming too much and qualifying too much are two faces of the same problem.

  10. #10
    Board Regular
    Join Date
    Apr 2002
    Location
    Campbell-Ewald
    Posts
    56
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default Re: Can an array formula reliably do this kind of totaling?

    OK, one more twist. If someone typed a bit of text in C8 of the original example, the =sumproduct(rng*rng) will fail due to the text value on that row. Any way to have sumproduct ignore text in this context? or treat it as a zero?

Some videos you may like

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •