Evenly distribute/divide a figure across several columns

bobthedino83

New Member
Joined
Oct 16, 2021
Messages
5
Office Version
  1. 2019
Platform
  1. Windows
Hi, everyone. Newbie here.
I've been using excel for 25+years since high school but I'm by no means a pro and this particular problem has got me stumped.

Context: (not important, so you can skip to problem below)
This is for a wine cellar. There's an app/website called Cellartracker(.com) that I use for cellar management. It's very powerful, if you like excel you'd like this platform.
It has a feature (which is why I started using it) called "ready to drink" whereby it outputs a "score" for each wine in your cellar which ranks that wine relative to all the other wines in your cellar in terms of what you should drink first.

The exact working of and rationale for this formula is contentious, but it's super useful when one has 1,000 bottles in the cellar and wants to know what to drink next. Most importantly it helps to avoid a disaster where bottles end up going off in one's cellar because they weren't consumed within their drinking window.

What it can't avoid though is what might be called a "wine tsunami". Which is when a lot of the bottles in a cellar hit their final year(s) all at the same time.
This is a real thing as people buy wines with the intention of drinking them in 5 or 10 or 15 years' time. Or one can buy a case of wine with the intention of drinking the 6 bottles over 10 years, starting in 5 years' time, for instance.

Problem: (note that wine and bottles are two different things)
Each wine has a drinking window, eg. 2019 - 2025
Each wine has a quantity of bottles present in your cellar, eg. 1, or 6, or 24, whatever

I want to spread the quantity of bottles for a wine across the remaining years left in the drinking window for that wine. This spread needs to be more or less even...
Simply dividing the number of bottles left into the remaining years will give me a fraction in some cases, which isn't going to work because I want to graph the bottles that are "scheduled" for drinking for each year for the next decade and you can't drink a fraction of a bottle (with a coravin, maybe, but I don't wanna).

If I were doing this by hand the columns would look like this:

Capture.JPG


Note one of the things I'd like to do is avoid drinking a bottle during the last year of it's drinking window, I've applied this rule to the example above.

With the wine in row 2 the solution could be some IF functions, but the problem for me comes in when there's fewer bottles than years, then I don't know how to get it to skip a year or two as in row 3....

Any advice on which formulas to use or if this requires macros (which I'm not really familiar with) would be greatly appreciated.
Thanks in advance!
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
A couple of ideas that you can try.
I edited cell K5 to 0 which remove the formula from that cell.

T202109a.xlsm
CDEFGHIJKLMNO
2BeginEnd20212022202320242025202620272028Net
320212028127222221100
42021203022110000000
52021203022101000
62021202574222100000
3b
Cell Formulas
RangeFormula
F3,F6F3=D3-C3
G6:N6,G3:N3G3=IF(COUNT($G$2:G$2)<=$F3,INT($E3/$F3)+MAX(0,MOD($E3,$F3)>=COLUMNS($G$2:G$2)),0)
O4:O6,G4:N4G4=IF(COUNT($G3:G3)<=$F4,INT($E4/$F4)+MAX(0,MOD($E4,$F4)>=COLUMNS($G4:G4)),0)
O3O3=SUM(G3:N3)-E3
J5,L5:N5L5=MIN(INT($E5/$F5),$F5-SUM($G5:K5))
 
Upvote 0
Welcome to the MrExcel board!

See if this would suffice. Column G needs to be blank (could be hidden)

21 10 17.xlsm
CDEFGHIJKLMNOPQR
2BeginEndQtyPer Yr2021202220232024202520262027202820292030Check
3201720234222        4
42021203020.222222222001000100 2
520212028121.7142857142122212   12
Spread
Cell Formulas
RangeFormula
H3:Q5H3=IF(H$2=MEDIAN(H$2,$C3,$D3-1),ROUND(COUNTIF($H$2:H$2,">="&$C3)*$F3-SUM($G3:G3),0),"")
R3:R5R3=SUM(H3:Q3)
F3:F5F3=E3/COUNTIFS(H$2:Q$2,">="&C3,H$2:Q$2,"<"&D3)
 
Upvote 0
Thanks guys! I'm going to try your suggestions and see if it gives me the insights that I'm looking for, will revert!
 
Upvote 0
Welcome to the MrExcel board!

See if this would suffice. Column G needs to be blank (could be hidden)

21 10 17.xlsm
CDEFGHIJKLMNOPQR
2BeginEndQtyPer Yr2021202220232024202520262027202820292030Check
3201720234222        4
42021203020.222222222001000100 2
520212028121.7142857142122212   12
Spread
Cell Formulas
RangeFormula
H3:Q5H3=IF(H$2=MEDIAN(H$2,$C3,$D3-1),ROUND(COUNTIF($H$2:H$2,">="&$C3)*$F3-SUM($G3:G3),0),"")
R3:R5R3=SUM(H3:Q3)
F3:F5F3=E3/COUNTIFS(H$2:Q$2,">="&C3,H$2:Q$2,"<"&D3)
Thanks Peter_SSs

This seems to be closest to what I'm looking for. However I'd like to make a few changes and seeing as I don't seem to be able to understand what your formulas are doing I haven't been able to make these changes myself:

1 - remove the prohibition on drinking wine on the last year of its drinking window (I tried, but it breaks everything)
2 - When the last year of a wine's drinking window is 2021 (1st year in span of years) I get a #DIV/0! error in the Per Yr cell and it doesn't add the quantity to the 2021 column

Lastly, the distribution of bottles across years is a bit inconsistent - sometimes they look like a normal distribution
e.g. 1 1 2 1 1 or 1 1 1 1 1
but other (most) times they're odd like
1 0 1 0 1 0 1 0 1 or 1 1 1 0 1 1

It'd be better, according to the wine snobs, to distribute quantities as a normal (bell curve) distribution, which makes sense i.t.o. wine ageing.
Your assistance is greatly appreciated!

Thanks again!
 
Upvote 0
A couple of ideas that you can try.
I edited cell K5 to 0 which remove the formula from that cell.

T202109a.xlsm
CDEFGHIJKLMNO
2BeginEnd20212022202320242025202620272028Net
320212028127222221100
42021203022110000000
52021203022101000
62021202574222100000
3b
Cell Formulas
RangeFormula
F3,F6F3=D3-C3
G6:N6,G3:N3G3=IF(COUNT($G$2:G$2)<=$F3,INT($E3/$F3)+MAX(0,MOD($E3,$F3)>=COLUMNS($G$2:G$2)),0)
O4:O6,G4:N4G4=IF(COUNT($G3:G3)<=$F4,INT($E4/$F4)+MAX(0,MOD($E4,$F4)>=COLUMNS($G4:G4)),0)
O3O3=SUM(G3:N3)-E3
J5,L5:N5L5=MIN(INT($E5/$F5),$F5-SUM($G5:K5))

Hi, Dave

Thanks for the input.

Your formula for row 3 looks a bit more like what I'm looking for (a bell curve type distribution).

Though I'm not sure what happened in row 5? Why did you make K5 zero and what about the first few cells in that row that are just blank?

Thanks again!
 
Upvote 0
Quick thoughts
My suggestion with some changes per your last message.

T202109a.xlsm
CDEFGHIJKLMNO
2BeginEnd20212022202320242025202620272028Net
320212028128222211110
420212030210110000000
520212030210110000000
62021202575221110000
720212021101100000000
3b_
Cell Formulas
RangeFormula
F3:F7F3=D3-C3+1
G3:N7G3=IF(COUNT($G$2:G$2)<=$F3,INT($E3/$F3)+MAX(0,MOD($E3,$F3)>=COLUMNS($G$2:G$2)),0)
O3O3=SUM(G3:N3)-E3
O4:O6O4=IF(COUNT($G3:O3)<=$F4,INT($E4/$F4)+MAX(0,MOD($E4,$F4)>=COLUMNS($G4:O4)),0)


Quick edit on Peter_SSs post
T202109a.xlsm
CDEFGHIJKLMNOPQR
2BeginEndQtyPer Yr2021202220232024202520262027202820292030Check
32017202341.33333333121       4
42021203020.2001000010 2
520212028121.521212121  12
3bbb
Cell Formulas
RangeFormula
H4:P5,H3:Q3H3=IF(H$2=MEDIAN(H$2,$C3,$D3),ROUND(COUNTIF($H$2:H$2,">="&$C3)*$F3-SUM($G3:G3),0),"")
R3:R5R3=SUM(H3:Q3)
Q4:Q5Q4=IF(Q$2=MEDIAN(Q$2,$C4,$D4-1),ROUND(COUNTIF($H$2:Q$2,">="&$C4)*$F4-SUM($G4:P4),0),"")
F3:F5F3=E3/COUNTIFS(H$2:Q$2,">="&C3,H$2:Q$2,"<="&D3)


Please review the above and advise if either is closer to your requirement.

Post a concise sample and expected results.
 
Upvote 0
"Your formula for row 3 looks a bit more like what I'm looking for (a bell curve type distribution)."
I did not try to provide a solution with a Bell Curve; your question stated evenly split.
My formula is primarily linear but does weight earlier year(s).

"Though I'm not sure what happened in row 5? Why did you make K5 zero and what about the first few cells in that row that are just blank?"
This shows that if you do not want the formula to work in the first few cells, just delete the formula in these cells.
 
Upvote 0
It'd be better, ..., to distribute quantities as a normal (bell curve) distribution
I don't think that can accommodate that into my formulas. Perhaps somebody else can?

the distribution of bottles across years is a bit inconsistent
It may appear that way to you, but it is very consistent and works on rounding since, as you pointed out, one cannot drink a part of a bottle for the year. Take row 4 below. There are 10 years in the date span so column F calculates that in theory 0.2 bottles could be consumed per year.
Y1: Calculation is 0.2 bottles. Don't open one.
Y2: Calc is now 0.4 bottled. Still don't open it.
Y3: Calc is 0.6. Since this is now closer to 1 than 0, open the bottle.
Y4: Calc is 0.8. This rounds to 1 but you already drank the bottle last year so don't open another one.
Y5: Calc is 1.0 but you drank it 2 years ago so don't open another one.
Y6: Calc is 1.2 which rounds to 1 but you drank it 3 years ago so don't open another one.
Y7: Calc is 1.4 which rounds to 1 but you drank it 4 years ago so don't open another one.
Y8: Calc is 1.6 which rounds to 2 and since you have only drunk 1 you can open another one.
Y9: Calc is 1.8 which rounds to 2 but you finished the second one last year.
Y10: Calc is 2.0 but you finished the second one two years ago.

The following still works with the same sort of rounding logic as above, but accommodates points 1 and 2 from post #5

bobthedino83.xlsm
CDEFGHIJKLMNOPQR
2BeginEndQtyPer Yr2021202220232024202520262027202820292030Check
32017202341.333333333121       4
42021203020.200100001002
520212028121.521212121  12
620182021333         3
Spread (2)
Cell Formulas
RangeFormula
H3:Q6H3=IF(H$2=MEDIAN(H$2,$C3,$D3),ROUND(COUNTIF($H$2:H$2,">="&$C3)*$F3-SUM($G3:G3),0),"")
R3:R6R3=SUM(H3:Q3)
F3:F6F3=E3/COUNTIFS(H$2:Q$2,">="&C3,H$2:Q$2,"<="&D3)
 
Upvote 0
I am thinking about why total bottles of each year were not taken into account?
If I own a cellar, I dont want like this:
There are only 4 bottle for 2021 (wine A), which is 1-2-1 bottle for 2021-2022-2023
Total bottles I can drink for 2021-2022-2023 is 1-5-5

Why I cannot drink like this 3-4-4 (= 11/3=3.6 bottles/year)? It mean, I can choose to drink more wine A in the first year.
Capture.JPG



Reading the context in #1, I think total of bottles in cellar, must be spreaded over years, take into account the year limitation of each wine.
 
Upvote 0

Forum statistics

Threads
1,214,919
Messages
6,122,259
Members
449,075
Latest member
staticfluids

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