# Summing a variable-valued column [closed]

I have a column of values (expenses, to be exact). The next column may have any of several flags, represented as letters. So it would look something like this:

$1,000 A$1,105 D

$2,150$5,213 D

I want the sum of values where the next column contains a given flag. I can do this by creating an intermediate column that contains either 0 or the flagged value (using an IF command), then summing that column.

Is there a way to do this without an intermediate column?

edit retag reopen merge delete

### Closed for the following reason the question is answered, right answer was accepted by Alex Kemp close date 2015-10-21 15:40:48.464862

Sort by » oldest newest most voted

For sure.

=SUMIF(FlagsColumn;Flag;ValuesColumn)

e.g. =SUMIF($B$2:$B$100;"A";$A$2)

Take a look in the LibreOffice help about the function.
p.d. Be sure the values to sum are numbers, not text representing numbers.

more

I could not get mariosv's formula to work if the flag is a blank cell. One work around is to sum all the cells and subtract the sum of all the non-blank key cells. Or insert a flag where none exists.

( 2013-02-10 01:31:10 +0100 )edit

IMO is best do the things explicit, and do not let it to an interpretation. Although is possible to do it with =SUMPRODUCT(ISBLANK($B$2:$B$100);$A$2:$A$100). But is more complicate to use regular expression.

( 2013-02-10 01:56:56 +0100 )edit

## Stats

Asked: 2013-02-09 23:10:52 +0100

Seen: 461 times

Last updated: Feb 10 '13