+ Reply to Thread
Results 1 to 10 of 10

Multiplication of values in same row if condition is met

  1. #1
    Registered User
    Join Date
    02-09-2012
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    18

    Smile Multiplication of values in same row if condition is met

    Hello there,

    i would like to have excel compute a sum of a previous multiplication of values which are in different columns but in the same row if in the very same row there is for example A1="string1" and B1="string2". that shud be performed over for example row 1 till row 2000...

    can this be done via a simple excel formula? i already tried sumifs and sumproduct but that didnt work out so far.

    thanks very much for your help!

  2. #2
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiplication of values in same row if condition is met

    Do you mean?

    =SUMIFS(sumrange,criteriarange1,criteria1,criteriarange2,criteria2)

    where criteria1 and criteria2 can be "string1" and "string2", respecitively.
    Where there is a will there are many ways.

    If you are happy with the results, please add to the contributor's reputation by clicking the reputation icon (star icon) below left corner

    Please also mark the thread as Solved once it is solved. Check the FAQ's to see how.

  3. #3
    Registered User
    Join Date
    02-09-2012
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Multiplication of values in same row if condition is met

    what i actually tried is this: SUMPRODUCT( (DATA III!$A$3:$A$2000="ST220") * (DATA III!$B$3:$B$2000="220R1") * (DATA III!$C$3:$C$2000="GW1") * (DATA III!$P$3:$P$2000) * (DATA III!$R$3:$R$2000))

    this however returned a #name? error...

  4. #4
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiplication of values in same row if condition is met

    You have to put DATA III in single quotes, e.g. 'DATA III'

  5. #5
    Registered User
    Join Date
    02-09-2012
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Multiplication of values in same row if condition is met

    thanks for the quick response! i tried that out but that doesnt help! excel infact removes the ' ' automatically so it looks like before...

  6. #6
    Registered User
    Join Date
    02-09-2012
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Multiplication of values in same row if condition is met

    SUMPRODUCT('DATA III'!$A$3:$A$2000="ST220", 'DATA III'!$B$3:$B$2000="220R1", 'DATA III'!$C$3:$C$2000="GW1", 'DATA III'!$P$3:$P$2000, 'DATA III'!$R$3:$R$2000) i now substituted the * by , and i got rid of the error. now however the formula returns 0, does anyone have an idea as to why this could happen? i know that there are exactly 4 lines in this DATA III sheet where the conditions are met but it seems no suming up of the multiplied values takes place....

  7. #7
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiplication of values in same row if condition is met

    Try it like:

    =SUMPRODUCT(--('DATA III'!$A$3:$A$2000="ST220"),--('DATA III'!$B$3:$B$2000="220R1"),--('DATA III'!$C$3:$C$2000="GW1"), 'DATA III'!$P$3:$P$2000, 'DATA III'!$R$3:$R$2000)

    I would be surprised the Excel removes the apostrophes in a sheetname with a space in it....

  8. #8
    Registered User
    Join Date
    02-09-2012
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Multiplication of values in same row if condition is met

    OMG, you are a genius!!! the -- before the string conditions did the trick!! thanks so much! so now my only question is, why was excel not smart enough to do without the -- and what does the -- actually do?

  9. #9
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiplication of values in same row if condition is met

    the dashes coerce TRUE/FALSE results from the conditional checks, into 1/0 results, so Sumproduct can do the math required.

  10. #10
    Registered User
    Join Date
    02-09-2012
    Location
    Tehran
    MS-Off Ver
    Excel 2010
    Posts
    18

    Re: Multiplication of values in same row if condition is met

    oh ok this seems very useful! i assumed a true or false would be treated as 1/0 automatically in a multiplication...

  11. #11
    Forum Expert NBVC's Avatar
    Join Date
    12-06-2006
    Location
    Mississauga, CANADA
    MS-Off Ver
    2003:2010
    Posts
    34,898

    Re: Multiplication of values in same row if condition is met

    In the original formula you use with the * between conditions, it would be treated that way, but not with the comma separators...

    More on Sumproduct here

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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