+ Reply to Thread
Results 1 to 13 of 13

Google Sheets: Add values based on top 2 numbers in separate column

  1. #1
    Registered User
    Join Date
    09-13-2022
    Location
    NY
    MS-Off Ver
    Google Sheets
    Posts
    6

    Google Sheets: Add values based on top 2 numbers in separate column

    Spent 2 days racking my brain on this one so I figured I'd seek some help.

    I need to add values from a table based on the rank of other values in a separate column.

    In my example, F2 and I2 would be added because H2 and K2 are the largest values among {E2,H2,K2}

    Ultimately, B2 will be (F2+I2)/(G2+J2)

    I've been able to get H2+K2 using SUMPRODUCT(LARGE({E2,H2,K2},{1,2})) but haven't figured out how to report the appropriate columns to the left.

    *N is numerator, *D is denominator, *S is the score derived from *N/*D

    Not sure if it's worth noting that each cols C:K are provided via VLOOKUP that reference different tables for each set of values (e.g. AN,AD, and AS all come from Table A)

    Any help is appreciated!
    Attached Files Attached Files

  2. #2
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Add values based on top 2 numbers in separate column

    One option:

    =SUMPRODUCT(LARGE(IF(RIGHT(E1:K1)="S",C2:I2),{1,2}))/SUMPRODUCT(LARGE(IF(RIGHT(E1:K1)="S",D2:J2),{1,2}))

  3. #3
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Add values based on top 2 numbers in separate column

    B2=
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    See the attached file.
    Notice my main language is not English.

    I appreciate it, if you reply on my solution.

    If you are satisfied with the solution, please mark the question solved.

    You can add reputation by clicking on the star * add reputation.

  4. #4
    Registered User
    Join Date
    09-13-2022
    Location
    NY
    MS-Off Ver
    Google Sheets
    Posts
    6

    Re: Add values based on top 2 numbers in separate column

    Oldere and Falcondude,

    These work for the example I gave, however, if the values in C2 and D2 were 1.9 and 2 respectively, the result should be different because .95 (E2) is larger than .8 (H2)

  5. #5
    Forum Expert 63falcondude's Avatar
    Join Date
    08-22-2016
    Location
    USA
    MS-Off Ver
    365
    Posts
    6,266

    Re: Add values based on top 2 numbers in separate column

    Try:

    =SUMIFS(C2:I2,E1:K1,"*S",E2:K2,">="&AGGREGATE(14,6,(RIGHT(E1:K1)="S")*(E2:K2),2))/SUMIFS(D2:J2,E1:K1,"*S",E2:K2,">="&AGGREGATE(14,6,(RIGHT(E1:K1)="S")*(E2:K2),2))

  6. #6
    Registered User
    Join Date
    09-13-2022
    Location
    NY
    MS-Off Ver
    Google Sheets
    Posts
    6

    Re: Add values based on top 2 numbers in separate column

    I'm sure this works, just not with gSheets. Is there a way to maybe use INDEX and FILTER to accomplish the same thing? My string at the top is also two words (Cox Score). In you previous formula I substituted "S" with "e" and it was fine...I think.

  7. #7
    Forum Expert
    Join Date
    05-30-2012
    Location
    The Netherlands
    MS-Off Ver
    Office 365
    Posts
    14,987

    Re: Add values based on top 2 numbers in separate column

    I'm sure this works, just not with gSheets.
    You post your question in Excel formula and functions and not in Google questions (Other platform).

    That is why you get solutions working in Excel.

    Advice: if a formula don't work, show the excel file with the not working formula, so forummembers can take a look at is.
    Last edited by oeldere; 09-14-2022 at 02:08 AM.

  8. #8
    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
    81,288

    Re: Google Sheets: Add values based on top 2 numbers in separate column

    I'm sure this works, just not with gSheets.
    How did you expect your helpers to provide a Google Sheets friendly solution when you had posted in the Excel section and not mentioned this crucial point until now?

    I have moved your thread to the correct forum section and re-titled it appropriately.
    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.

  9. #9
    Registered User
    Join Date
    09-13-2022
    Location
    NY
    MS-Off Ver
    Google Sheets
    Posts
    6

    Re: Google Sheets: Add values based on top 2 numbers in separate column

    Because I'm new and not completely aware of the differences between the platforms. Sorry.
    Last edited by AliGW; 09-14-2022 at 09:19 AM. Reason: Please DON'T quote unnecessarily!

  10. #10
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,074

    Re: Google Sheets: Add values based on top 2 numbers in separate column

    Solution for Google Sheets:

    EDITED
    Please Login or Register  to view this content.
    See example file:
    https://docs.google.com/spreadsheets...gid=2100307022
    Last edited by janmorris; 09-14-2022 at 02:43 PM.
    As a gesture off appreciation, you can click * Add Reputation at the foot of any of the posts of members who helped you reach a solution.

    And finally, was your problem solved? if so, please click Thread Tools above the first post of your enquiry, then select [Solved]

  11. #11
    Registered User
    Join Date
    09-13-2022
    Location
    NY
    MS-Off Ver
    Google Sheets
    Posts
    6

    Re: Google Sheets: Add values based on top 2 numbers in separate column

    I've updated my sample sheet to include all the basic info I'm working with. I apologize for not doing this sooner. Honestly thought I could figure it out with just a little direction but that is not the case. Definitely a case of not knowing what I don't know.

    Janmorris, when I blew this up to fit my data it gave me #VALUE.

    It needs to calculate the sum of "NUM" divided by the sum of "DEN" for the top 4 "SCORES". If there aren't 4 "SCORES", it would accept less. In my true sheet, the "X" is generated instead of #N/A but I can make it display anything if it's easier. Column C can be filtered to display rows with 4 or more scores.

    Again, sorry for being a noob. I sincerely appreciate the help.

    Updated file: is in previous post by Janmorris. Since I'm a noob I can't insert links into my posts yet lol.

  12. #12
    Valued Forum Contributor janmorris's Avatar
    Join Date
    07-24-2021
    Location
    Japan
    MS-Off Ver
    Google Sheets (& Mac 2021)
    Posts
    1,074

    Re: Google Sheets: Add values based on top 2 numbers in separate column

    this has turned out to be a typical XY problem.

    it would do you well to read the information on the following link: https://xyproblem.info/

    Now added to the file is new sheet "Corrected" where all X are removed, allowing the QUERY to complete without errors.
    Last edited by janmorris; 09-16-2022 at 04:05 PM.

  13. #13
    Registered User
    Join Date
    09-13-2022
    Location
    NY
    MS-Off Ver
    Google Sheets
    Posts
    6

    Re: Google Sheets: Add values based on top 2 numbers in separate column

    Janmorris, that's the ticket!! Thanks so much.

    I am very much guilty of the XY thing, without even intending to, which I think is the point in the article. The article was very insightful and I appreciate the referral.

+ 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. Google Sheets: How to pull row numbers from different sheets based on date (Solved)
    By qcguys in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 13
    Last Post: 01-09-2022, 03:36 PM
  2. Return column headers for all true values in Google Sheets
    By tim34 in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 3
    Last Post: 03-30-2021, 02:57 AM
  3. [SOLVED] Google Sheets - Generating a Sequential list based on previous values
    By lalalalalala in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 9
    Last Post: 12-13-2019, 07:05 AM
  4. email row contents based on cell values (google sheets populated by google forms)
    By reedg in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 0
    Last Post: 01-13-2016, 02:55 PM
  5. Average numbers based upon separate column
    By FreeThrow in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 07-08-2011, 01:32 AM

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