Search code examples
google-sheetsfiltersumsumifssumproduct

Total of items in column where another column equals a value


I have the following structure

Column1 Column2
Foo     100
Baa     200

How can I have a value that is the sum of all column2 values where its column1 value is equal to Foo?


Solution

  • a lot of solutions for this like:

    =SUMIF(A1:A; "Foo"; B1:B)
    
    =SUMIFS(B1:B; A1:A; "Foo")
    
    =INDEX(SUM((A1:A="foo")*B1:B))
    
    =SUM(FILTER(B1:B; A1:A="Foo"))
    
    =SUMPRODUCT(B1:B*(A1:A="Foo"))
    
    =QUERY(A1:B; "select sum(B) where A = 'Foo'")