0
votes

I have the following code which I'm using in my Google Spreadsheet.

=ArrayFormula(sumif(month(income!A$2:A), month(A2) , income!B$2:B))

There are two sheets, main and income.

Income sheet contains payments received in every month. (there are multiple payments in each month). So I sum up earnings in a month and display them as monthly earning in main sheet.

The problem is - since it only considers month, when we have april 2014 and april 2015, the total sum for april in main sheet counts both years.

I am trying to figure out how to use year+month in the formula. Any help?

1

1 Answers

0
votes

I just figured it out using the TEXT function.

Here's what I did:

=ArrayFormula(sumif(text(income!A$2:A, "mmm yyyy"), text(A2, "mmm yyyy") , income!B$2:B))

The first value in sumif is this:

text(income!A$2:A, "mmm yyyy")

It basically fetches month and year from all rows in column A in income sheet.

The second value is:

text(A2, "mmm yyyy")

It fetches month and year from A2 cell in main sheet.

Those two are compared. And we get the result. Problem solved.