+ Reply to Thread
Results 1 to 6 of 6

Sum Range + Divide by another range

  1. #1
    Registered User
    Join Date
    08-28-2007
    Posts
    3

    Sum Range + Divide by another range

    Having trouble with a formula. Not very experienced. Maybe you guys can help. Example: My data has a classifier in column J. If cell J34 and cell J42 has a "1", I want to multiply G34 times H34 and then add this to G42 times H42 and then divide this by the sum of G34 and G42 for a weighted average.

    Thanks in advance for any help

  2. #2
    Forum Expert
    Join Date
    03-23-2004
    Location
    London, England
    MS-Off Ver
    Excel 2019
    Posts
    7,064
    =IF(AND(J34=1,J42=1),(G34*H34+G42*H42)/(G34+G42),"J34 or J42 not equal 1")


    You havent said what happens if J34 or J42 dont equal 1
    so Ive just generated a piece of text to that effect
    Regards
    Special-K

    Ensure you describe your problem clearly, I have little time available to solve these problems and do not appreciate numerous changes to them.

  3. #3
    Registered User
    Join Date
    08-28-2007
    Posts
    3
    I should have been more specific. If any row in column J has a "1", I want to multiply the data in column G times column H of that row. This will repeat for any row that has a "1" and the "1's" will not be in consecutive rows. Then the sum of the multiplications will be added together and divided by the sum of data in column G that has a corresponding "1" in column J. I hope this is a better explanation.

    Thanks

  4. #4
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523

    Try this

    Here's a formula which should work using the assumption that your data is in G1-G6, H1-H6 and your classifier is in J1-J6:

    =SUMPRODUCT(G1:G6,H1:H6)/SUMIF(J1:J6,"=1",G1:G6)

    Obviously you need to change the G1-G6 etc cell references to the actual references you're using in your spreadsheet.

  5. #5
    Registered User
    Join Date
    08-28-2007
    Posts
    3
    Thanks but I only want to sumproduct the rows that have a "1" in column J

  6. #6
    Valued Forum Contributor
    Join Date
    08-31-2007
    Location
    SW Ireland
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2311 Build 16.0.17029.20068) 32-bit
    Posts
    523
    My apologies for missing that- this revised formula allows for the value in column J:

    =SUMPRODUCT(G1:G6,H1:H6,J1:J6)/SUMIF(J1:J6,"=1",G1:G6)

+ 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