I'm working on developing a simulation model in Excel for a class project, and I have ran across this odd problem. My model is basically to simulate a tram path with multiple stations. To make it simpler, I have created this Excel sheet to demonstrate my model and issue:
http://i.stack.imgur.com/8qhD2.png
As you can see above, this is the information of riders who are arriving at station 1 and wanting to go to station 2, 3 and 4 respectively.
In the cells B3 to D3, I have this formula:
=ROUND(BETA.INV(RAND(), 4, 4, 0,6),0)
In the cell B4, I have this formula:
=IF($E$3>8,IF(B3=0,0,RANDBETWEEN(1,B3)),B3)
and finally, in the cells B6, I have:
=B3 - B4
Now, the tram capacity is only 8 riders at a time, so the total number in cell E4 cannot exceed 8. Is there a way I can tell Excel to do the following:
If the total number of people in cell E3 is greater than 8, then randomly select numbers of riders who can get on the tram based on the number of riders who want to go to each station so long that the total number in cell E4 does NOT exceed 8 (just as demonstrated in the screenshot above).
If the total number of people in cell E3 is less than or equal to 8, then the same number in cells B3 - D3 should carry over to cells B4 - D4.
Hopefully my explanation is clear enough. Any thoughts on how to achieve this?
I don't think excel could do that as this involves recursive iteration. One workaround is you could generate lots of test case that try to form up the 8 if it is more than 8, then you can pick the success one as your answer.
You may take a look at my implementation. Here is the Link.
Related
I need your help, after many tries and searches here I couldn't yet reach my goal.
This is excel-formula doubt.
My A1 from sheet Tags contains the following values as example:
adm
as
ad
b02
b02_e11
b02_e14
b807-10_e3
b807-10_e4
b807_e1
batch
bp
... and many more entries.
with the following formula I was able to collect only matching values starting with b:
{=IFERROR(INDEX(Tags!$A$1:$A$999,SMALL(IF(LEFT(Tags!$A$1:$A$999,1)=$A$7,ROW(Tags!$A$1:$A$999)),ROW(1:1)),1),"")}
A7 from Summary sheet contains the character b.
the result of the above formula returns to me the following sequence:
b02
b02_e11
b02_e14
b807-10_e3
b807-10_e4
b807_e1
batch
bp
But I don't want to have in the sequence the values batch or bp or any other value that starts with b and do not have an number after, I'm just want values like b0, b1, ... , b8.
To reach my goal I have tried many workarounds like adding the following formula and an array inside:
=COUNT(FIND({0,1,2,3,4,5,6,7,8,9},A1))>0
Between my current IF statement:
{=IFERROR(INDEX(Tags!$A$1:$A$999,SMALL(IF(AND(LEFT(Tags!$A$1:$A$999,1)=$A$7,COUNT(FIND({0,1,2,3,4,5,6,7,8,9},B2))>0),ROW(Tags!$A$1:$A$999)),ROW(1:1)),1),"")}
*B2is where I suppose to paste the formula since B1 contains the header.
The above formula returns many 0's to me.
I hope I could give you enough information and sorry if I couldn't be more precisely I'm not yet able to paste images here.
Thank you,
Rodrigo
I find that AGGREGATE makes it easier to add additional conditions.
=IFERROR(INDEX(tags!A:A, AGGREGATE(15, 6, ROW($1:$999)/((LEFT(tags!A$1:A$999, 1)=$C$3)*(ISNUMBER(--MID(tags!A$1:A$999, 2, 1)))), ROW(1:1))), TEXT(,))
I've also reduced some redundant characters and minimized cell range references.
I'm trying to write a (what I assume should be rather simple) excel formula and having quite some difficulty getting it to work... Basically I want to:
Divide value of a cell by 3
For each group of 3 return x, for each remainder return y
Find the sum of x and y
So say I'm selling raffle tickets for $40 each, but if someone buys three the price drops to $100 for that three, and the next one is back to $40 until they reach another pack of 3...
Ex.
1 would cost 50, 2: 40, 3: 100, 4: 140 5:180, 6: 200 and so on and so forth...
Any help is greatly appreciated, excel formuals are really not my strong suite :/ If it were another programming language it would be so much easier I think...
I think you could use the following formula:
First set the price and discount info in range B1:B3.
Write this formula in cell B6: =B5*B1-QUOTIENT(B5,B2)*B3 (use comma instead of semicolon (as shown on screenshot) if you're not working on a Danish computer like I am).
The price in cell B6 then updates when you adjust the number of tickets you want to buy in cell B5.
Best regards,
Simon
I am trying to simulate a portfolio rebalancing strategy with Excel.
Assuming there are 10 stocks each with a target allocation weight and an upper and lower band that is acceptable. If the band is exceeded in either direction, rebalancing is mandated. Each stock has a different weight. I am now trying to come up with an if statement to compare the actual allocation weight (after simulated returns) of each stock with its individual upper/lower band.
E3:E13 is the actual allocation weight after returns of a period.
C3:C12 is the lower acceptable value
D3:D12 is the higher acceptable value.
I tried the following formula to populate a cell with either "yes" (= rebalance) or "no" (= not rebalance) based on which the next term allocation will be based:
=IF(E3:E12<$C$3:$C$12,"yes",IF(E3:E12>$D$3:$D$12,"yes","no"))
I was hoping this would compare E3 with C3, E4 with C4 etc, and also E3 with D3, E4 with D4, and so forth. Unfortunately, the formula does not create the right output, it often says "no" when some of the bands are exceeded. How could I fix this?
Something like this? You need to compare a cell's value with 2 other cells, then you can use OR (in case you want to match either) ... or you may use AND (if you want to match both cells)
EDIT: Based on your request - you can use an ArrayFormula to get that (press Ctrl+Shift+Enter)
I'm trying to make a revision timetable for myself on Excel.
Let's say I'm doing four exams, A to D. Each exam has a certain number of "practice papers" that I have to do. Below is a demonstration table on Excel:
ExamName NoOfPapers
ExamA 4
ExamB 5
ExamC 7
ExamD 1
There is another table, with two columns: MonthDate and the paper I want to practice on that da. So,
May Paper?
1
2
.
.
.
29
I want to make it work so that if I put ExamA in the field under Paper?, it would automatically deduct 1 from the NoOfPapers of ExamA, to make it 3, so I make sure I'm not repeating the paper too many times.
If I only had 17 papers, it would have been easy to do it manually. But unfortunately I have 99 papers to do (exactly 99 :P).
How can I implement this on a cell as an IF statement (or any other possible way) on Microsoft Office Excel?
Thank you! :)
change the title of the column "NoOfPapers" to "OriginalNoOfPapers". Then create a column next to it called "NoOfPapersRemaining".
Assuming the cell with "ExamName" is A1, use the following formula in C2: =B2 - COUNTIF(Z:Z, A2)
(this also assumes that the column called "Paper?" is in column Z... in real life change it to the correct column on your spreadsheet.
I made four columns in row 1, Exam Name, Exam Total, Completed,Remaining. The completed column has the function
=Countif(B:B,A:A)
in roww 2, 3, 4, 5. The remaining columns are
D2="SUM(B2-C2)"
D3="SUM(B3,C3)"
D4="SUM(D4,C4)"
D5="SUM(D5,C5)"
In row 7 I have three columns, Date Complete, Exam Name, Paper. Exam Name must = The exact same as Cell A2:A5. All you would need is to enter the date and the exam name and it will show the total papers done and the remaining.
This can be better but does what I believe you asked. For instance, use of conditional formatting. If there is a deadline, add a column for the date and use conditional formatting to display an approaching deadline. Freeze row 7 to see remaining after entering a lot of dates in cell A8.
Hope this helps. I'm not a pro but like learning more about Excel.
UPDATE 1:
This is what I am trying to do.
B1, B2, and B3 represent 3 containers
Period could be anything, days, weeks, months years, so Period 1, can mean day 1, or week 1, or month 1 or year one.
In period 1, I start off with the value 100. 60% of 100 always gets added to B1 (container 1), and 40% of 100 always gets added to B2 (container 2). B3 (container 3 does not get a percentage of 100. This happens on every period.
After the first period, i.e. period 2, B1, B2, and B3 all get 10% of the value of the previous B2 values divided by 3. So each container gets 1.33 in this example. However, B1 also gets another 60% of 100 added to it making the total 61.33 and B2 gets another 40% of 100 added to it making the total 41.33.
In the next period, period 3, again 10% of the values from B2 above period 3 divided by 3, i.e. ((40+41.33)*0.10)/3 gets added to all cells in period 3, then for B1, add another 60% of 100, and B2 get another 40% of 100.
ORIGINAL QUESITON:
I have the following spreadsheet which uses some basic formulas.
https://spreadsheets.google.com/spreadsheet/ccc?key=0Al-CN3-vjUYvdEdNMU4zN3FTNF9VZlMzZXBTcjh0Mnc&hl=en_US#gid=0
As you can see this goes from period 1 to 12. Is it possible to create a formula for columns B1, B2, and B3 to get the values based on the period? So, for example, if the formula was working, I would be able to simply type in 5 to get:
B1 = 65.61
B2 = 45.61
B3 = 5.61
Used = 500.00
If I type in 100 as the period, it should return the correct values, instead of creating 100 rows with the appropriate formulas per cell, which would take ages to do.
Does anyone know how to create the required formulas?
As shown online in your spreadsheet, you can use SUMIF:
For B1:
=SUMIF(C2:C13;A4;D2:D13)
And so on for B2, B3 and Used.
EDIT
I solved your issue on another Sheet of your Google Doc.
Needed some maths to found out which kind of sequence this was in order to sum up each element to the n-th one.
This was done for column E (meanly title B2):
=$A$2*$I$8*POWER($I$2/3+1;C2-1)
And then adapted to fit B1, B3 and Used, wasn't that easy...
For Ease Why dont you convert
=(((E2+E3+E4+E5+E6+E7+E8+E9+E10+E11+E12)*I2)/3)+(A2*I5)
to
=((SUM(E2:E12)*I2)/3)+(A2*I5)
Before all this math stuff isn't my best Art, but I figure out the answer anyways
Well, even when you can macro your function, some understanding of the formulae can help to a simpler answer:
First, the key column is B, if you analize his result you will identify this as a ''series'' (the math stuff, link to wikipedia here), checking of the results are calculated yield the followin table:
please, don't force to explain, because isn't my best area of expertise, but this is the solution (use a scientific calculator or mathematica to check this out), using this formulae you getthe value of the B column.
So, Column A and C, how we get it? A quick inspection show the following:
A=B+20
C=B-40
I hope this solves your question
Best Regards
Alen