Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SUMIF with multiple criteria using formula in the criteria

Sample workbook for this problem can be found here
https://docs.google.com/spreadsheets/d/1IkNv6outjKzwgvnG_7IPLpSt2vEAtcrq/edit?usp=share_link&ouid=117355411294900898171&rtpof=true&sd=true

I have a table in excel that looks like this.

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What I want, is to create this table from the data.

enter image description here

If that’s all I needed, then I could just use a pivot table, but for reasons unimportant here, that’s not a possible solution.

I can use SUMIF(Category, "Car", Amount) to get the data for say all of cars, but this doesn’t work with two variables.

Thus, I go to SUMIFS(Table1[Amount], YEAR(Table1[Date]), 2021, Table1[Category], "Car"), but this throws a "problem with this formula error" and won’t accept it. Btw, this doesn’t work whether I use a cell reference or write in the criteria information.

Maybe there is an answer using SUMPRODUCT or arrays or something, but it’s beyond me.

I found a solution that looks like this
=SUMIFS(Table1[Amount], Table1[Category], "car", Table1[Date], ">=01/01/"&C22, Table1[Date], "<=12/31/"&C22). Where C22 is the year "2022" or whatever and "car" could be replaced by a cell reference easily enough. This works, but doesn’t feel elegant. Is there a better way?

>Solution :

As you said you can use SUMPRODUCT:

=SUMPRODUCT(Table1[Amount], (YEAR(Table1[Date])=2021)*(Table1[Category]="Car"))

Note with office 365 SUMPRODUCT can be just SUM

or use the SUMIFS as you show.

=SUMIFS(Table1[Amount], Table1[Category], "car", Table1[Date], ">=01/01/"&C22, Table1[Date], "<=12/31/"&C22)

You could also use (with office 365):

=SUM(FILTER(Table1[Amount], (YEAR(Table1[Date])=2021)*(Table1[Category]="Car")))

But that is just a variation of the SUMPRODUCT.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading