excel - how to sum with an interval -


i looking formula or macro can employ following: need sum-square amount per week. should done beginning on. data structure follow:

col   col b   column c year    week    amount 2000    1       368 2000    2       8646  …      …       … 2000    52      46846 2001    1       656 2001    2       846  …      …       … 2001    52      4651 2002    1       489  …      …       … 2014    52      46546 

i have column d in have sum-squared of amount per week. cell(column "d", "week 2000w1") should be,

=sumsq(amount 2000w1) 

for first year, easy. problem occurs in next year. in cell (column "d", week "2001w1") formula should be,

=sumsq(amount 2000w1;amount 2001w1) 

for last year, cell (column "d", week "2014w1") should formula,

=sumsq(amount 2000w1;amount 2001w1; amount 2002w1;amount 2003w1;amount 2004w1; amount 2005w1;amount 2006w1;amount 2007w1; amount 2008w1;amount 2009w1;amount 2010w1; amount 2011w1;amount 2012w1;amount 2013w1) 

this should done weeks 1 till 52 years. there quick way this?

this solution worksheetfunction, can develop similar macro too, think it's easier without it:

=sumsq(index([amount]*([week]=[@week])*([year]<=[@year]),0))

enter image description here


Comments