Help SUMIF with YTD

shepcs

Board Regular
Joined
Feb 2, 2003
Messages
72
Office Version
  1. 365
Platform
  1. Windows
Would greatly appreciate any help as its driving me nuts.
I'm trying to do a YTD summation given a value to lookup in a single column (Column C), then doing a ytd in the Jan-Dec columns (E:P).
So for Inputs I have a number to lookup in a column and a date (in this case E2: 400101 and E3: 05/31/22)

For a single value its no problem, I do
=SUMIF($C:$C,E3,INDEX($E:$P,,MATCH(E2,$E$6:$P$6,0)))

And I know the YTD formula works but this is inputting a specific row (E12:P12) instead of location the row by the input number E2
=SUMIF($E$6:$P$6,"<="&E2,E12:P12)

I'm trying to combine the two and running into a problem.

Really appreciate any insight.
Thanks!!
 

Attachments

  • SUMIF Help3.JPG
    SUMIF Help3.JPG
    243.9 KB · Views: 24
How is it that you have A:A4# in your workbook? There is not an array producing expression in cell A4 (in what I copied over.) I'm not sure what range of cells that expression is meant to include?
 
Upvote 0

Excel Facts

Lock one reference in a formula
Need 1 part of a formula to always point to the same range? use $ signs: $V$2:$Z$99 will always point to V2:Z99, even after copying
Thanks awoohaw. But I was trying to sum Jan-May. So 400101 should be 40,230,630
 
Upvote 0
How is it that you have A:A4# in your workbook? There is not an array producing expression in cell A4 (in what I copied over.) I'm not sure what range of cells that expression is meant to include?
I might have fat fingered that. I just changed it to A:A and still didnt work. I was trying to say search the entire column A for that Dept Partner number (That pegs the row), then by the desired YTD date (May) in this case, sum all months in columns up to and including May. Again the only inputs being a department number and YTD Date (May).
 
Upvote 0
okay this is jan to may:
Book1
ABCDEFGHIJKLMN
1
2RAW Data
3DEPT2022-01-312022-02-282022-03-312022-04-302022-05-312022-06-302022-07-312022-08-312022-09-302022-10-312022-11-302022-12-311905-07-14
44001009866446.46198636.86198636.86198636.811768273.614485169.6447785600000099494360
5400101-587340.07-388978.11-242392.4047-17025.1807-33785.4168-55537.9333-134921.82700000-1459980.94
6400160372033.93372033.93372033.93372033.93372033.93372033.93372033.937378533.937378533.937378533.935292577.435292577.4335324994.16
74001700000000000000
84001710000000000000
9
10Reporting Page
11Date Input2022-05-31
12YTD May Output
13Dept Input400100#REF!40,230,630.40
14Dept Input400101#REF!(1,269,521.18)
15Dept Input400160#REF!1,860,169.65
16Dept Input400170#REF!-
17Dept Input400171#REF!-
Sheet3
Cell Formulas
RangeFormula
C13:C17C13=SUM(FILTER(FILTER($B$4:$M$8,(MONTH(B$3:M$3)<=MONTH($B$11))),A:A#=B13))
D13:D17D13=SUMPRODUCT((--($B13=$A$4:$A$8))* (--(MONTH($B$11)>=MONTH($B$3:$N$3)))* (--(1<=MONTH($B$3:$N$3))) *($B$4:$N$8))
 
Upvote 0
Solution
Thanks Awoohaw! That totally worked. I really appreciate the help. I'll now try to figure out what its doing. I changed it to October as a test and for some reason it was including hte annual "2022" column N. Not sure why but I tweaked your formula to exclude it. Thank you again!
SUMIF HELP.xlsx
ABCDEFGHIJKLMN
1
2RAW Data
3DEPTJan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-222022
44001009,866,4466,198,6376,198,6376,198,63711,768,27414,485,17044,778,560-----99,494,360
5400101(587,340)(388,978)(242,392)(17,025)(33,785)(55,538)(134,922)-----(1,459,981)
6400160372,034372,034372,034372,034372,034372,034372,0347,378,5347,378,5347,378,5345,292,5775,292,57735,324,994
7400170-------------
8400171-------------
9
10Reporting Page
11Date Input08/31/22
12YTD May Output
13Dept Input40010099,494,360
14Dept Input400101(1,459,981)
15Dept Input4001609,982,771
16Dept Input400170-
17Dept Input400171-
Sheet1 (2)
Cell Formulas
RangeFormula
C13:C17C13=SUMPRODUCT((--($B13=$A$4:$A$8))*(--(MONTH($B$11)>=MONTH($B$3:$M$3)))*(--(1<=MONTH($B$3:$M$3)))*($B$4:$M$8))
Cells with Conditional Formatting
CellConditionCell FormatStop If True
B11Expression=#REF!<>0textYES
E1Expression=#REF!<>0textYES
B10:B11Expression=#REF!<>0textYES
G1:M1,C1,B10:B11,N1:N2Expression=#REF!<>0textYES
 
Upvote 0
it is matrix math. it calculates zeros and ones to multiply by the entire data grid, if you only want 2023, then insert this somewhere in the multiplication:
(--(2023=Year($B$3:$M$3))
 
Upvote 0
you can see how it works by highlighting each section between asterisks, press F9 to see the calculations. But, don't hit enter after that, press escape or ctrl Z to back it out.
 
Upvote 0
The formula I originally supplied works, once the ranges are change to your new layout
Fluff.xlsm
ABCDEFGHIJKLMN
1
2RAW Data
3DEPT31/01/202228/02/202231/03/202230/04/202231/05/202230/06/202231/07/202231/08/202230/09/202231/10/202230/11/202231/12/20222022
44001009866446.46198636.86198636.86198636.811768273.614485169.6447785600000099494360
5400101-587340.07-388978.11-242392.4047-17025.18068-33785.41683-55537.93334-134921.826800000-1459980.942
6400160372033.93372033.93372033.93372033.93372033.93372033.93372033.937378533.937378533.937378533.935292577.435292577.4335324994.16
74001700000000000000
84001710000000000000
9
10Reporting Page
11Date Input31/05/2022
12YTD May Output
13Dept Input40010040230630.4
14Dept Input400101-1269521.182
15Dept Input4001601860169.65
16Dept Input4001700
17Dept Input4001710
Main
Cell Formulas
RangeFormula
C13:C17C13=SUMPRODUCT(($A$4:$A$8=B13)*($B$3:$M$3<=B$11)*($B$4:$M$8))
 
Upvote 0

Forum statistics

Threads
1,223,908
Messages
6,175,304
Members
452,633
Latest member
DougMo

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