How to use sumproduct in Apple Numbers

Hi Apple Numbers Community,


I'm fairly new to Apple Numbers, trying to move from Google Sheets to Numbers if I can do what I want.

I like the fact that we can have multiple tables in 1 sheet. That's the main reason why I would switch.


However, I'm trying to play with sumproduct, but I don't manage to make it work.


What I want to achieve is basically sum several values for a given month.



Here's my code in Google Sheets (it works):

IF($A3 <= TODAY() ; SUMPRODUCT((MONTH($A3) = MONTH('other-sheet'!$V$3:$V)) * 
(YEAR($A3) = YEAR('other-sheet'!$V$3:$V)) * 'other-sheet'!$AA$3:$AA) ; )


Here's my code in Apple Numbers (it does not work):

IF($A3 ≤ TODAY() ; SUMPRODUCT((MONTH($A3) = MONTH(other-table::$O$3:$O1002)) × 
(YEAR($A3) = YEAR(other-table::$O$3:$O1002)) × other-table::$S$3:$S1002))


Any idea?

MacBook Pro 13", macOS 10.14

Posted on Apr 28, 2019 12:48 PM

Reply
Question marked as Top-ranking reply

Posted on Apr 29, 2019 11:36 AM

"What I want to achieve is basically sum several values for a given month."


What you need to do this is SUMIFS


Table 1 (left):

Column A contains the dates of each line. These are Date and Time values, with the time part automatically set to 00:00:00 (midnight, at the beginning of that day) by Numbers when only the date part is entered.

Column B: The values to be summed. For simplicity, I've made them all the same, so the sum for each month is 5 * the number of entires in that month—easy to check.


Table 2 (right)

This is a summary table.

Column A contains the Date and Time of the beginning of each month to be summed, with only the date part entered (and displayed).

Column B contains the formula shown below the table, entered in B2 (with A2 replacing both occurrences of A5 shown), then filled down to the last cell in the column. The screen shot shows the formula as it appears in B5. the text verson below is from B2.


B2: SUMIFS(Table 1::B,Table 1::A,">="&A2,Table 1::A,"<"&EDATE(A2,1))


For a number in column B of Table 1 to be included in the sum, the date in column A of the same row as that number must meet two conditions:

It must be on or after ( >= ) the date in 'this row' of column A of 'this table'.

It must be before ( < ) the same date one month after the date in 'this row' of column A of 'this table' ( EDATE(A2,1) )

Three values meet those conditions for January, so the sum in Row 2 is 15.


Regards,

Barry



3 replies
Question marked as Top-ranking reply

Apr 29, 2019 11:36 AM in response to Ennicolem

"What I want to achieve is basically sum several values for a given month."


What you need to do this is SUMIFS


Table 1 (left):

Column A contains the dates of each line. These are Date and Time values, with the time part automatically set to 00:00:00 (midnight, at the beginning of that day) by Numbers when only the date part is entered.

Column B: The values to be summed. For simplicity, I've made them all the same, so the sum for each month is 5 * the number of entires in that month—easy to check.


Table 2 (right)

This is a summary table.

Column A contains the Date and Time of the beginning of each month to be summed, with only the date part entered (and displayed).

Column B contains the formula shown below the table, entered in B2 (with A2 replacing both occurrences of A5 shown), then filled down to the last cell in the column. The screen shot shows the formula as it appears in B5. the text verson below is from B2.


B2: SUMIFS(Table 1::B,Table 1::A,">="&A2,Table 1::A,"<"&EDATE(A2,1))


For a number in column B of Table 1 to be included in the sum, the date in column A of the same row as that number must meet two conditions:

It must be on or after ( >= ) the date in 'this row' of column A of 'this table'.

It must be before ( < ) the same date one month after the date in 'this row' of column A of 'this table' ( EDATE(A2,1) )

Three values meet those conditions for January, so the sum in Row 2 is 15.


Regards,

Barry



Apr 28, 2019 1:58 PM in response to Ennicolem

Without seeing your tables I'm finding it hard to visualize what you are trying to do with your formula. I think you want to sum or count the values in column S of 'other-table' that have the same month and year in column O as the date in A3 of the table in which you inputing your formula. If so then "Numbers way" would be to use COUNTIFS or SUMIFS. Numbers doesn't support the "array formula" form of SUMPRODUCT, which predates the adoption of COUNTIFS and SUMIFS in most spreadsheet apps.


More on SUMIFS and COUNTIFS here and here. If you are running Numbers in another language then you can switch to your language on that site.


If you post specifics of what you are trying to do somewhere here can suggest how to use those functions.


BTW, the ability of Numbers to easily have multiple tables on one sheet means you generally won't want to have such wide tables (up to column S, etc.).


SG


Apr 29, 2019 9:59 AM in response to SGIII

Hi SG,


Thanks for your answer.


I want to create a sheet to follow my stock trading buy and sell according to a French strategy.


What you said made me think about how I could split my giant table into smaller ones. I ended up with smaller tables but I still need the "sumproduct" to know my performance for each month.


I'll get back to you once I am more advanced with the new sheet I am building based on your suggestions.

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.

How to use sumproduct in Apple Numbers

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