Search code examples
google-sheetsgoogle-apps-scriptscripting

How to calculate results based on values from two different columns in apps script?


I'm somewhat of a beginner with Google Sheets and Apps Script and I want to know if the following is possible:

visual description

enter image description here

Focusing on the weightclass and amount columns, I want to add the amount on the left to the total on the right for each weightclass. The problem with countif's as displayed in the picture is that I don't know how to incorporate the amounts into the total, only displaying how many times "FW" literally showed up in A column etc.

Any suggestions or workarounds to this? Thanks

Open to Apps Script suggestions, not sure if this is solvable inside Sheets


Solution

  • If I understood you correctly, you can achieve it with this formula:

    =sumif(G3:G7, G3, H3:H7)
    

    Where G3:G7 is the weightclasses column, G3 is the particular class you are counting (it can be just text "FW"), and H3:H7 - the amount column.