0
votes

Is there a function that allows me to calculate the total value of column B if column A is equal to "some text". I'm making a budget for myself.

Currently, my Google Spreadsheet looks something like this:

----A---- -----B----    
     food         50
  alcohol         20
     food        120
    dance         10
   garden         20
     food         20
    dance         10

I would like to get the total amounts like this:

----E---- -----E---- 
     food        190
  alcohol         20
    dance         20
   garden         20

I can use an if statement on a single cell but how do I do it over several cells and SUM values together? So the if statement would be =if(A1="food",B1,0)

2

2 Answers

0
votes

You can use SUMIF

=SUMIF(range to be matched, criteria,sum range)

in your case it would be

=SUMIF($A$1:$A$7,E1,$B$1:$B$7)

assuming A1:A7 is "food, alochal, dance etc) E1 is food (criteria) and B1:B7 is the figures (sum range)

0
votes

One option is to use the function: QUERY.

=QUERY(A1:B7; "SELECT A, SUM(B) GROUP BY A LABEL A '', SUM(B) ''")

QUERY

More information: Query Language Reference