Tuesday, October 06, 2009

Excel: sumif - using a SQL where clause in Excel

While doing testing today I needed to add all the values in column F by "Male" and "Female". I learned the amazing "sumif" function.
The syntax is


SumIf( range to filter by, criteria to filter, sum_range to be filtered)


excel
In my case the first argument was a range in column B, my filter was "Male", and the range to actual sum was in column F.

=SUMIF($B$2:$B$641,"Male",F$2:F$461)


excel
Since I was summing based on multiple items like "Male", I told Excel to use the column to the left to be my filter value.

=SUMIF($B$2:$B$641,$E649,F$2:F$461)


The criteria can be things like ">10".

No comments: