+ Reply to Thread
Results 1 to 9 of 9

Right syntax for SUMPRODUCT and SUM functions combined.

  1. #1
    Registered User
    Join Date
    05-16-2021
    Location
    Saint-Petersburg
    MS-Off Ver
    MS Office 365
    Posts
    13

    Right syntax for SUMPRODUCT and SUM functions combined.

    Hello every one!

    Can you, please, help me with an advice on how to improve my formula, so that the second part of the formula with SUM function would include only numbers, which are above non-zero numbers? Just to give a background: this is a kind of returns calculations with weights. The range by which I divide the sumproduct is the weight.

    Just to clarify, maybe I need a kind of criteria for SUM function which states SUM only if the cells below SUM range are non-zero.

    To be more clear, I attach a sample file.

    Thank you beforehand!
    Attached Files Attached Files
    Last edited by Orif; 05-31-2021 at 06:23 AM.

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,400

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    The what you want column INCLUDES the NOW column in the calculation, so it's wrong.

    The calculation you already have works fine - zeroes do not affect it. Just change the IFERROR final "0"n to just 0 so that it does not return text.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Expert Pepe Le Mokko's Avatar
    Join Date
    05-14-2009
    Location
    Belgium
    MS-Off Ver
    O365 v 2402
    Posts
    13,443

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    And, once again, beware of the IFERROR function. It hides ALL errors which may not be be what you want

  4. #4
    Registered User
    Join Date
    05-16-2021
    Location
    Saint-Petersburg
    MS-Off Ver
    MS Office 365
    Posts
    13

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    Hi, AliGW!

    Thank you for the answer and advice about IFERROR. I was not aware of that previously.

    Maybe I was not successful in explaining what I want, but yes, the column already includes the the now column, and additionally, it includes the cell, which is not related to it. I mean, If you look at cells DKO7 and DKP7, you can see that the numbers are different. Just because DKO7 includes 1 unnecessary cell from above.

    Many thanks!

  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    79,400

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    Sorry - I don't know what you mean by 'unnecessary cell'. Which cell is 'unnecessary' and why?

    The fact of the matter is this: SUM with a range including zeroes will disregard the zeroes, so you really do not need to use SUMIF. It would be different if you were counting, not summing, of course.

    You need to explain in WORDS what you are trying to achieve, because it really isn't clear.

  6. #6
    Registered User
    Join Date
    05-16-2021
    Location
    Saint-Petersburg
    MS-Off Ver
    MS Office 365
    Posts
    13

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    Okay, I am really sorry, that I couldn't explain it in details.

    So, I will try to explain in the example of cell DKO7 and DKP7. The formula, which is =SUMPRODUCT(A6:DKN6;A7:DKN7)/SUM(A6:DKN6); is aimed to calculate the weighted average of numbers in Row7. The first part of the formula multiplies each cell in Row7 and Row6 - this part is totally okay. After multiplying the Row7 and Row6, I need to divide the result by sum of weights which are represented in Row7. The issue is the following: if in DKO7 in the second part of the formula SUM(A6:DKN6), I select the whole range of Row6, then it sums the cell DKI6. The formula gets wrong since by including DKI16, I artificially increase the weight. For that reasons I would like my formula not to include DKI6, DKJ8, DKK12 etc.

    I hope it helps a bit.

  7. #7
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,412

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    I think you need SUMIF (to sum row 6 if row 7 >0) instead of SUM only:
    DKO7:
    Please Login or Register  to view this content.
    Quang PT

  8. #8
    Registered User
    Join Date
    05-16-2021
    Location
    Saint-Petersburg
    MS-Off Ver
    MS Office 365
    Posts
    13

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    Yes, Bebo!!! Thank you very much!!!
    I was crawling around this SUMIF, but did not know how to specify criteria for the range

    I have another finalizing question concerning the previous replies - how can I change this formula so that I have numbers, not strings?

  9. #9
    Forum Expert bebo021999's Avatar
    Join Date
    07-22-2011
    Location
    Vietnam
    MS-Off Ver
    Excel 2016
    Posts
    9,412

    Re: Right syntax for SUMPRODUCT and SUM functions combined.

    Quote Originally Posted by Orif View Post
    how can I change this formula so that I have numbers, not strings?
    There is no text value in your data.
    Do you mean "0" in DKO2? just use this for first row DKO2:
    =SUMPRODUCT(A2:DKN2*A2:DKN2)/SUMIF(A2:DKN2,">0",A2:DKN2)
    The from DKO3:
    =SUMPRODUCT(A2:DKN2*A3:DKN3)/SUMIF(A3:DKN3,">0",A2:DKN2)

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Is this proper syntax for a combined AND/OR If statement?
    By Ulnarian in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 03-25-2020, 11:54 AM
  2. [SOLVED] SUMPRODUCT and INDIRECT functions not working with a ROW reference when combined
    By Duoae in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 04-04-2014, 03:28 AM
  3. [SOLVED] LEFT and SUMPRODUCT functions combined
    By DeZeeuw2 in forum Excel Formulas & Functions
    Replies: 10
    Last Post: 02-27-2014, 11:36 AM
  4. SUMPRODUCT combined with other functions
    By tweety127 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-13-2008, 12:30 PM
  5. [SOLVED] Can Sumproduct and MAX/MIN be combined?
    By all4excel in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 04-02-2008, 04:47 PM
  6. Combined Functions
    By fncuis in forum Excel General
    Replies: 4
    Last Post: 08-22-2005, 07:16 PM
  7. Combined VBA line syntax
    By Neal Zimm in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-04-2005, 06:06 PM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1