Error when adding amounts in week 1 that spans 2 years

TomParkD

New Member
Joined
Jun 14, 2011
Messages
6
I have an array formula below that adds transactions for each week. This works OK until I come to a week1 which starts on 30 December 2013 and ends 5 January 2014. My work sheets spans more than 1 year, 2013-2015. The answer that I get takes only the transactions in 2014 ie week 1, 1-5 January 2014 and week 1 which starts 29 December 2014 and ends 31 December 2014. How can get the formula to take week 1 being the last part of December 2013 and the first part of January 2014?

=
SUM(((NominalCodes=$D129)+(WeekNumberTB=(J$11))=2)*NetAmount*(CalendarYear=YEAR(J$12)))

<tbody>
</tbody>


j12= 05/01/14

Thanks for your help!
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December
Hello, I would have to see a sample of your data, but I suspect you could use SUMIFS instead of an array formula.

Can you use a helper column in your data, that would probably be the quickest and easiest solution to use a formula to determine the year. If not, you may be able to use something like CalendarYear=MIN(YEAR(J$12),YEAR(beginning date cell reference (where 30 December 2013 is stored)), but I am really just guessing not knowing your data and layout.
 
Last edited:
Upvote 0
Hello, I would have to see a sample of your data, but I suspect you could use SUMIFS instead of an array formula.

Can you use a helper column in your data, that would probably be the quickest and easiest solution to use a formula to determine the year. If not, you may be able to use something like CalendarYear=MIN(YEAR(J$12),YEAR(beginning date cell reference (where 30 December 2013 is stored)), but I am really just guessing not knowing your data and layout.

The formula - same for every week- looks for WeekNumber - and the calendar year Week 51 is OK (22-Dec-13) as with the year formula it can only be in the year 2013. In the year 2014 week 1 ending 5-Jan-14 has transactions in 2014 but week 1 ending 4-Jan-15 also has transactions in 2014. My formula adds all 2014 transactions

51521
22-Dec-1329-Dec-1305-Jan-14
(2,069.01) 1,343.49 (2,069.01)
(1,720.88) 8,288.01 (10,593.48)

<tbody>
</tbody><colgroup><col span="2"><col></colgroup>


51521
21-Dec-1428-Dec-1404-Jan-15
- - -
(28,355.78) 107,098.00 (42,063.81)

<tbody>
</tbody><colgroup><col><col span="2"></colgroup>















<tbody>
</tbody><colgroup><col span="2"><col></colgroup>
 
Upvote 0
From what you posted and explained above, I'm still not sure what you need and if one of the posted examples is okay and one is not.

In both examples, since the beginning date is from the prior year (starting dates are 30 dec 13 and 29 dec 14 respectively, do those amounts belong to year 2013 and year 2014 respectively?

Where it is week 1, are you saying those are actually week 52 for years 2013 and 2014?

To get the Calendar Year in the formula, can you use something like:

CalendarYear=MIN(YEAR(J$12),YEAR(J$12-6))
 
Upvote 0
Just remove CalendarYear part, is it work?

=SUM(((NominalCodes=$D129)+(WeekNumberTB=(J$11))=2)*NetAmount)
 
Upvote 0

Forum statistics

Threads
1,220,965
Messages
6,157,119
Members
451,398
Latest member
rjsteward

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