SUMIFS using date function

I have a table containing Dates, Categories and Amounts. From it I would like to create a second table containing the total amount in various categories over a number of years, something like this :-



I can do it in a fairly hard-coded way for each year using something like SUMIFS($Amount,$Category,"="&$A7,$Date,">="&"1/1/2020",$Date,"<="&"31/12/2020"), but to avoid having to edit that for each year I'd like to do something like SUMIFS($Amount,$Category,"="&$A7,YEAR($Date),"="&C$1). Sadly, that gives me the dreaded "SUMIFS requires that all range arguments are the same size.


Any ideas would be greatly appreciated.

iMac, macOS 10.13

Posted on Jan 10, 2025 8:50 AM

Reply
Question marked as Top-ranking reply

Posted on Jan 13, 2025 3:19 PM

That's unfortunate, since pivot tables were designed to streamline this exact kind of thing because they're a PITA to craft manually.


All is not lost, though, since your data isn't that complex.


The simplest solution would be to add another column to your data table, which calculates the YEAR() of the row's date. This column can be hidden afterwards if you don't want to see it.



The formula of cell B2 is simply:


=YEAR($A2)


Now you have a simple way to use SUMIFS() since you have common values (year and category):



In this table, cell B2's formula is:


=SUMIFS(Data::$D,Data::$C,"="&$A2,Data::$B,"="&B$1)


This sums the values in column $D on the data table based on matching column $C with cell $A2 (the category) along with column $B in the Data table with cell B$1


This formula can be filled across and down the table to get you your results.

5 replies
Question marked as Top-ranking reply

Jan 13, 2025 3:19 PM in response to peterppan

That's unfortunate, since pivot tables were designed to streamline this exact kind of thing because they're a PITA to craft manually.


All is not lost, though, since your data isn't that complex.


The simplest solution would be to add another column to your data table, which calculates the YEAR() of the row's date. This column can be hidden afterwards if you don't want to see it.



The formula of cell B2 is simply:


=YEAR($A2)


Now you have a simple way to use SUMIFS() since you have common values (year and category):



In this table, cell B2's formula is:


=SUMIFS(Data::$D,Data::$C,"="&$A2,Data::$B,"="&B$1)


This sums the values in column $D on the data table based on matching column $C with cell $A2 (the category) along with column $B in the Data table with cell B$1


This formula can be filled across and down the table to get you your results.

Jan 10, 2025 11:00 AM in response to peterppan

This is literally a 4-click process.


Assuming your source data has columns labelled 'Category', 'Date' and 'Amount':


With your source table selected, choose Organize -> Create Pivot Table


In the Inspector you should see the various columns listed, along with how you want them summarized.


Drag the Category' field to the Rows box

Drag the Date field to the Columns box (it will summarize by year by default)

Drag the Amount field to the Values box (it will sum the values by default)




Done.

Jan 15, 2025 8:16 AM in response to peterppan

peterppan wrote:

I don't really understand why $Date,">="&"1/1/2020" doesn't give me an error whereas YEAR($Date),"="&C$1 does.


Numbers does not support keeping an 'array' of years calculated by YEAR($Date) in memory. So instead you have to first put the array of results in cells first (e.g., Camelot's extra column) and refer to that instead.


In contrast, $Date,">="1/1/2020" test-values, condition pair does not involve an array of calculated values.


SG

Jan 14, 2025 6:59 AM in response to Camelot

Going back to my original example, I don't really understand why $Date,">="&"1/1/2020" doesn't give me an error whereas YEAR($Date),"="&C$1 does.


Anyway, thank you so much for your help and patience. I think your suggestion is the best way of doing this - better than using Categories which I had been messing about with since my original post!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

SUMIFS using date function

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.