# How do I best sum data in a table in google sheet based on a set of criteria?

I have a table with 14 columns (see attached image):

First column (column A) is the name of the expense

Column 2-13 (column B-M) is the months January to December (with January = 1, February = 2… December = 12)

Column 14 (column N) is a grouping of the expenses.

In the table in each of the month columns (column B-M), the expense for that month is entered.

E.g., in the first column one expense could be called “LinkedIn ads” and another expense could be called “facebook ads” and then they would both be called “Marketing expense” in column N.

Now, I would like to be able to dynamically SUM all expenses that match a combination of a specific month (columns B-M) and a specific group (column N).

For example, let say I would like to sum all the expenses for March (column D) that are grouped as “Marketing expenses” column (N)

I tried some combination of IF formulas with SUM and SUMIF but cannot seem to make it work.

Use `filter()`, like this:
`=sum( iferror( filter( filter(B2:M, B1:M1 = month("1 March")), N2:N = "Marketing costs" ) ) )`