Excel: Is there a formula that sums based on horizontal and vertical criteria?

This is kind of nerdy, but…well, I’m an accountant. It would be odd if it wasn’t nerdy. Most of the time when I’m using multiple criteria to add, my data is all going in the same direction. I’m using criteria only in columns or only in rows. SUMIFS is the perfect tool for that problem in Excel. What if I have criteria in both rows and columns? Is there a tool for that?

Typical Problem

Here is the typical problem with the typical solution.

ABCDEFG
1MONTHLOCATIONEMPLOYEESALES
2JanuaryMitchellJeff1,235
3JanuarySioux FallsJoe987
4JanuaryMitchellMary2,352
5FebruaryMitchellJeff1,502
6FebruarySioux FallsJoe1,358
7FebruaryMitchellMary1,268

If I wanted a sum of all the Sales in Mitchell by Jeff, here is the formula:

=SUMIFS(D2:D7,B2:B7,”Mitchell”,C2:C7,”Jeff”)

My Problem

My problems was that I had a monthly budget that I wanted to use for reporting Year to Date amounts. Here’s the example:

ABCDEFG
11/31/252/28/253/31/254/30/255/31/256/30/25
2Mortgage1,5001,5001,5001,5001,5001,500
3Utilities350350300250250200
4Groceries400450400450400300
5Vacation000001,800

In the video I show this more fully, but imagine you need the total of for Utilities year to date through April. What would you do?

=SUMIFS(B2:G5,A2:A5,”Utilities”,B1:G1,”<=DATE(2025,4,30)”) gives you an error. By the way, I used the date function, but typically I would just have a cell (like A1) where I plug in the date.

Try SUMPRODUCT:

=SUMPRODUCT((B2:G5)*(A2:A5=”Utilities”)*(B1:G1<=DATE(2025,4,30)))

I’ve been using this function for 20 years but still don’t understand it all the way. Here is the general format: =SUMPRODUCT((Sum Range)*(Criteria Range & Criteria)*(Criteria Range 2 & Criteria 2))

You can add as many criteria as you want. It works pretty slick.


Leave a Reply

Discover more from JCT Accounting Co

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

Continue reading