Search code examples
google-sheetssumgoogle-sheets-formulagoogle-sheets-querygoogle-query-language

How do I add up the value of column B if column A meets a certain condition for each value in column A with one formula?


Below is an example of the values I'm trying to add. My goal is not to use the filter formula for every line again. This is because it takes a lot of resources from the processing power that google sheets uses.

The words in the left list below occur several times in combination with a certain number. I want to have a unique list as shown on the right where the values from the left row add up when the words are equal (without using a filter formula for each line).

enter image description here

This formula

=arrayformula(vlookup(A:A, A:B, 2, FALSE))) 

comes very close, but returns only one value even though there are multiple matches. I want all values that matches returned.

enter image description here


Solution

  • try:

    =QUERY(A:B, "select A,sum(B) where A is not null group by A label sum(B)'summed'", 1)