Home > Blockchain >  How in Excel calculate the sum of all values from a table column matching conditions - like in SQL
How in Excel calculate the sum of all values from a table column matching conditions - like in SQL

Time:08-06

How in Excel calculate the sum of all values from a table column matching conditions - for example, the values in one column must equal the value given?

The following example shows well what I mean:

Example

Using SQL to do something like this would be easy

SELECT sum(fee) FROM excel WHERE year='2022' AND month='February';

But what is the best way to do something like this in Excel?

CodePudding user response:

You need SUMIFS() function. Try-

=SUMIFS(C2:C7,A2:A7,2022,B2:B7,"February")

Also can utilize FILTER() like-

=SUM(FILTER(C2:C7,(A2:A7=2022)*(B2:B7="February")))

enter image description here

  • Related