PLEASE HELP!!! SUMIF and SUBTOTAL NIGHTMARE

SpreadsheetPhil

New Member
Joined
Feb 25, 2020
Messages
9
Office Version
  1. 2016
Platform
  1. Windows
I'm trying to SUM the financial data in a column on an Excel Data Table if it has a date within another column that falls between 2 dates. I've tried the below formula, but it just keeps on returning £0.00. No idea where I'm going wrong. Can anyone help?

=SUMPRODUCT(SUBTOTAL(9,OFFSET($G$2:$G$2654,ROW($G$2:$G$2654)-MIN(ROW($G$2:$G$2654)),,1)),--($D$2:$D$2654>=1/1/2014),--($D$2:$D$2654<=31/12/2014))
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
I believe the issue may be in your data format. Try this:
=SUMPRODUCT(($D$2:$D$2654>=DATE(2014,1,1))*($D$2:$D$2654<=DATE(2014,12,31))*($G$2:$G$2654))
 
Upvote 0
You're almost there. It now sums correctly. However, I can't then get a SUBTOTAL if I filter on the table. Any thoughts on how I can add that in as that is the critical element? I've tried it like this, but it won't work - says 'Too few arguments':

=SUMPRODUCT(SUBTOTAL(9,OFFSET(($M$2:$M$2654>=DATE(2014,1,1))*($M$2:$M$2654<=DATE(2014,12,31))*($F$2:$F$2654))
 
Upvote 0
I'm not following. My earlier suggestion creates arrays that perform the logical tests to determine if the date criteria are met, essentially creating a logical filter that when multiplied by the financial data array and then summed, the result is the subtotal (i.e., the total of only the data meeting the filtering criteria). Do you wish to apply an actual "filter" to the table also? If so, then I see your point...as the SUMPRODUCT formula doesn't "see" the other filter. An advanced filter may address your needs and offer more flexibility, as other criteria can be easily added. See one implementation below. Shown is the moment before application of the advanced filter. After application [under Data > Advanced Filter (Sort & Filter block) > and then highlighting the data table (A5:C13) and filter criteria (E1:G2) and selecting the option to filter in place], the table collapses to show only the rows whose date criteria are met. The subtotal formula in A3 will update to show the subtotal for only the displayed rows. I've included the earlier SUMPRODUCT formulas (one with the desired date limits, the other with much wider limits) for comparison. Would this work better?

MrExcel_problem-solving.xlsx
ABCDEFGH
115110<--subtotal for SUMPRODUCTdatedateclient
228609<--total for SUMPRODUCT>=1/1/2014<=12/31/2014*
328609<--subtotal for other filter (either quick or adv)
4
5DataDateClient
6250012/15/2013A
7100012/31/2013B
8541/1/2014C
97896/15/2014C
1065439/15/2014B
1123412/15/2014A
12749012/31/2014A
1399991/1/2015C
14
Sheet12
Cell Formulas
RangeFormula
A1A1=SUMPRODUCT(($B$6:$B$2658>=DATE(2014,1,1))*($B$6:$B$2658<=DATE(2014,12,31))*($A$6:$A$2658))
A2A2=SUMPRODUCT(($B$6:$B$2658>=DATE(1900,1,1))*($B$6:$B$2658<=DATE(2100,12,31))*($A$6:$A$2658))
A3A3=SUBTOTAL(9,A6:A2658)
 
Upvote 0
You're almost there. It now sums correctly. However, I can't then get a SUBTOTAL if I filter on the table. Any thoughts on how I can add that in as that is the critical element? I've tried it like this, but it won't work - says 'Too few arguments':

=SUMPRODUCT(SUBTOTAL(9,OFFSET(($M$2:$M$2654>=DATE(2014,1,1))*($M$2:$M$2654<=DATE(2014,12,31))*($F$2:$F$2654))
I think you're looking for:

=SUMPRODUCT(SUBTOTAL(103,OFFSET($M$2,ROW($M$2:$M$2654)-ROW($M$2),0))*($M$2:$M$2654>=DATE(2014,1,1))*($M$2:$M$2654<=DATE(2014,12,31))*($F$2:$F$2654))
 
Upvote 0
Eric,
Thanks for offering this nice solution to compute the sum of a data column in a table with constraints/filters.
 
Upvote 0

Forum statistics

Threads
1,214,869
Messages
6,122,015
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top