Splitting costs based on inconsistent weeks

ljohnson88

New Member
Joined
Jul 28, 2021
Messages
5
Office Version
  1. 2010
Platform
  1. Windows
Good afternoon!

I am having serious trouble creating a formula that can split a cost dependent on how many weeks are in an accounting period.

My workplace has accounting periods 1 through to 12 and runs October through to September; so October is P1, November is P2, December is P3 etc. Periods 1,2,4,5,7,8,10 and 11 are 4 weeks long. Every third period 3,6,9,12 is 5 weeks long. So If I have A1 Start Date, B1 End Date, C1 Net Cost, D1 - O1 as P1 - P12, I would like a formula in D2 - O2 that calculates the split of the cost in cell C2 based on the dates in A2 and B2. Is this even achievable?

The working week is Thursday to Wednesday and I was told that in a newer version of Excel I could use a WEEKNUM formula? But because it is an older version, the Thursday - Wednesday working week would throw the formulas out as soon as you get to the New Year?

I have tried to set up a long list of separate formulas where by it divides the cost into the total amount of weeks and then a separate formula to multiply it again individually by the amount of weeks in that period, but this is a long process and does not take the dates into consideration. We are going to be entering anywhere between 100-300 rows of data per period, so having a date and cost manual entry only would be ideal!

Any help on this would be greatly appreciated.

Thank you.
 

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Hi LJohnson88,

A few questions:
  1. So on 10th October every year the week resets to 1 and the period resets to 1?
  2. If so then does week 2 start on the following Thursday? (e.g. for 2020 the 1st October is a Thursday so week 2 starts 8th October, but for 2022 the 1st October is a Saturday so week 2 would start Thursday, 6th October?)
  3. What is the earliest date you would ever enter?
 
Upvote 0
If I go by the new financial year coming, this starts on Thursday 30th September 2021. Then this follows the 4,4,5 pattern of weeks until Wednesday 28th September 2022. Then the new year would start Thursday 29th September 2022.

In the date from and to columns we would simply enter the beginning Thursday of that period and the final Wednesday of that period respectively.

Also, if it makes another difference, I have now been told we have access to a 2019 version of Excel in the building which this sheet can be used on.

Many thanks
 
Upvote 0
It's still not clear how the start of year is calculated so I'll assume it's a week 53 avoidance, but however it's calculated I'd just use a table for your calculation.

So here I've a Calendar sheet to show the period for each date (I have up to 2032, hence 4128 rows). You'll need to adjust after comparing with your schedule.

LJohnson88.xlsx
ABCDEF
1DateWeekPeriodWeekPeriod
29/30/20201111
310/1/20201121
410/2/20201131
510/3/20201141
610/4/20201152
710/5/20201162
810/6/20201172
910/7/20202182
1010/8/20202193
1110/9/202021103
Calendar
Cell Formulas
RangeFormula
C2:C11C2=IF(B2=B1,C1,INDEX($F$2:$F$53,MATCH(B2,$E$2:$E$53,0)))
E3:E11,A3:A11A3=A2+1
B3:B11B3=IF(MOD(ROW()-2,7)=0,IF(B2+1=53,1,B2+1),B2)


The calculation then becomes COUNTIFS and I added the Days column to simplify the calculation.

LJohnson88.xlsx
ABCDEFGHIJKLMNOP
1PERIOD
2Start DateEnd DateNet Cost123456789101112Days
329-Sep-2110-Oct-21$ 1,000.00$ 1,000.00$ -$ -$ -$ -$ -$ -$ -$ -$ -$ -$ -12
429-Sep-2128-Nov-21$ 1,000.00$ 459.02$ 459.02$ 81.97$ -$ -$ -$ -$ -$ -$ -$ -$ -61
529-Sep-2128-Sep-22$ 1,000.00$ 79.45$ 76.71$ 95.89$ 76.71$ 76.71$ 95.89$ 76.71$ 76.71$ 95.89$ 76.71$ 76.71$ 95.89365
606-Jun-2107-Jun-21$ 1,000.00$ -$ -$ -$ -$ -$ -$ -$ -$ 1,000.00$ -$ -$ -2
Entry
Cell Formulas
RangeFormula
D3:O6D3=COUNTIFS(Calendar!$A$2:$A$4218,">="&$A3,Calendar!$A$2:$A$4218,"<="&$B3,Calendar!$C$2:$C$4218,D$2)/$P3*$C3
P3:P6P3=COUNTIFS(Calendar!$A$2:$A$4218,">="&$A3,Calendar!$A$2:$A$4218,"<="&$B3)
 
Upvote 0
Wow... thank you very much for this. I would not have even known where to start. I think the only problem is that it needs to be exact divisions. So even if the date to date only goes 1 day into another period, it still needs an equal split.

So for example if the cost of £1,000 was all of P1 all of P2 and 'x' days of P3, it would still need to return P1 £307.69, P2 £307.69, P3 £384.62. Would this be achievable?

Thank you so much.
 
Upvote 0
I'm not sure what you mean by "'x' days of P3". I can't see how a portion of P3 would be so much greater than the whole of P1 or P2?

The calculation is done by number of days in each period. You can check that by removing the "/$P3*$C3" from the end and instead you'll get the number of days in each period for the given dates.
e.g. If your Start Date was 25-Sep-2021 and your End Date was 10-Oct-2021 then, because you said the new year starts 29-Sep-2021, it would report 4 days in P12 (25 Sep to 28 Sep) and 12 days in P1 (29 Sep to 10 Oct). NOTE: This also demonstrates that if dates go over a financial year the periods in D2 to O2 will include all values as no Financial Year is specified for the headings.
 
Upvote 0
If the £1,000 cost is to be split over a quarter and the cost landed on the 15th Jan, then the cost on paper would need to be split 15th Jan - 15th March, the return value however does not need to split it by number of days in a period; instead it just needs to recognise what periods that cost has travelled through and split it equally by either 4 weeks or 5. So in this example it has gone Jan - March.
Jan and Feb in our company has 4 weeks in them, so they need 4 weeks allocated to them (£307.69 each). March has 5 weeks so that needs 5 weeks allocated to it (£384.62).

I'm not 100% sure why they want it doing this way, but this is the way it has been requested by the higher ups. And as usual in my company, they have not provided any assistance with how this is actually going to be done! They seem to think that manually dividing a cost by the total number of weeks and then multiplying it by that periods weeks is a suitable solution for hundreds of rows of data.

A friend of mine has just provided me with the below. This seemingly works fine until it splits the cost across four, or more than four months; then it starts totaling the values incorrectly. In between each Period are hidden columns with weeks 1-52 and that same formula. He said he used WEEKNUM return 14 so that it recognises a Thursday start date.

I really appreciate the help.


1627555415280.png
 
Upvote 0
It does seem an unusual approach but have a go... OK, I believe I have a beautifully ugly solution still using the daily calendar approach.

Using a work area (here I'm just using some rows below but I can move to another sheet once you've confirmed the calculation) I can check if dates in the range are in a certain period and store that period/weeks number (4 or 5). Then take the 4 or 5 for that period, divide into the total period/weeks for that row and multiply by the cost.

Please run some sample dates and costs to verify.

Cell Formulas
RangeFormula
D3:O7D3=D12/$P12*$C3
A12:C16A12=A3
D12:O16D12=IF(COUNTIFS(Calendar!$A$2:$A$4218,">="&$A3,Calendar!$A$2:$A$4218,"<="&$B3,Calendar!$C$2:$C$4218,D$2)>0,D$11,0)
P12:P16P12=SUM(D12:O12)


Here's the calendar sheet again (which I've verified for 2021 and 2022 start). Just copy A56:C56 down to row 4218.

Cell Formulas
RangeFormula
C2:C56C2=IF(B2=B1,C1,INDEX($F$2:$F$53,MATCH(B2,$E$2:$E$53,0)))
A3:A56A3=A2+1
B3:B56B3=IF(MOD(ROW()-2,7)=0,IF(B2+1=53,1,B2+1),B2)
 
Upvote 0
Solution
You absolutely beautiful human being...

That works perfectly. I am guessing that I could just extend the period 1-12 on the Entry tab by another P1-12 using the same formulas if a cost was say to go over two/three years?

This is absolute genius... Thank you so much.
 
Upvote 0
You're welcome!

...but if you may go over years (as I mentioned earlier) then you'll need the FY as a part of the calculation.... so here's the Calendar sheet again but with a column for the FY

Cell Formulas
RangeFormula
C2:C56C2=IF(B2=B1,C1,INDEX($H$2:$H$53,MATCH(B2,$G$2:$G$53,0)))
D2:D56D2=IF(AND(B2=1,C2=1),YEAR(A2),D1)
A3:A56A3=A2+1
B3:B56B3=IF(MOD(ROW()-2,7)=0,IF(B2+1=53,1,B2+1),B2)
 
Upvote 0

Forum statistics

Threads
1,215,029
Messages
6,122,760
Members
449,095
Latest member
m_smith_solihull

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