Extend time depending on working days per week - excel-formula

I am trying to build dynamic time schedule with function, that will take in consideration how many days/week will be working days.
All lighter green cells are changeable, user inputs data in there. White color cell with header END is calculated. My current formula is located in Column END (it is affecting bar) and result should be:
As it is 5 working days/week bar should be until Mo 18
As it is 6 working days/week bar should be until We 13
As it is 7 working days/week bar should be until Su 10
I don't think this is much help, but as rules are requiring to post what has been tried yet, here it is:
IF(G10>6;D10+F10-1;IF(G10<=5;(D10+F10-1)+CEILING((F10/7);1)*2;(D10+F10)+CEILING((F10/7);1)
G10 = WD/W
D10 = START
E10 = END
F10 = DAYS
How it should be edited to work correct?

Assuming no holidays, you can use the following formula in E10 and copy down:
=(D10+IF(WEEKDAY(D10,2)>G10,8-WEEKDAY(D10,2),0))+F10+((ROUNDUP((F10+((WEEKDAY((D10+IF(WEEKDAY(D10,2)>G10,8-WEEKDAY(D10,2),0)),2))-1))/G10,0)-1)*(7-G10))-1
In column H I used a COUNTIF function to count the number X's in order to verify the right number of days were represented.

Related

Row a Trend Switches Up or Down

Not sure which functions or combination of possibly vlookup, index, match, or aggregate will work best for this. So far I have spent more than two weeks and can't seem to determine what works. SO, thank you greatly for the one who can figure this puzzle out.
My goal is to determine how to write a formula that will show these results. My guess is that second formula etc. will be different from the initial as it will start with the row specified from the initial formula as we are interested in knowing what row a trend begins moving up or down based on the given change value.
Based on change of value .15
Results need to be:
13 Up (initial formula)
23 Down (continuing from row 13 ???)
Etc.
Based on change of value .10
Results need to be:
13 Up (initial formula)
17 Down (continuing from row 13 ???)
19 Up (continuing from row 17 ???)
Etc.
Hopefully I am explaining this well. Thank you, thank you, thank you to the person who can figure this out.
1 277.54
2 277.50
3 277.43
4 277.47
5 277.49
6 277.50
7 277.40
8 277.39
9 277.44
10 277.42
11 277.36
12 277.28
13 277.23
14 277.50
15 277.54
16 277.55
17 277.58
18 277.56
19 277.46
20 277.57
21 277.60
22 277.67
23 277.71
24 277.67
25 277.43
26 277.35
Here is one of my many attempts. =AGGREGATE(15,6,ROW(1:26)/(($A$1-A2:A26)>=$I$1),1)+1
First row of >= to .15 difference (row 8) is not adequate
Image showing inadequate result
Because the uptrend based on a change of .15 actually started up at row 13.
Correct example
Image of what it should look like:
What it should look like image
Well finally I have an answer. You will need two more columns to do it on my way (which I think you can hide).
First step - To know when a new trend starts, put this formula in your B2 and pull down till B26
=IF(A1-A2)(A2-A3)<0,IF(A2-A3<0,"Up","Down"),"")
Now you have on B exacly when started a new trend and which trend*
EDIT: Now use this formula on B2. After, you need to pull it also to B1 to generate data, and pull down until B26). After pull to B1, don't pull down directly from B1, because there will be an error in the formula, always pull from mid rows formulas. You need to close it with ctrl+shift+enter
=IF(OR(ROW(A2)=SMALL(ROW($A$1:$A$26),1),ROW(A2)=LARGE(ROW($A$1:$A$26),1)),"tail",
IF((A1-A2)*(A2-A3)<0,
IF(ABS(A2-INDIRECT("A"&LARGE(IF(LEN($B$1:B1)>0,ROW($B$1:B1),""),1)))>$K$1,
IF(A2-INDIRECT("A"&LARGE(IF(LEN($B$1:B1)>0,ROW($B$1:B1),""),1))<0,"Up","Down"),
""),
"")
)
Second step - To know when your value jumped >= than the value you input in cell K1 (e.g 0.15), put this formula in your C2 and pull down till C26 (close it with ctrl+shift+enter, it's an array formula)
=IF(ABS(A2-A1)>=$K$1,LARGE((1(LEN($B$1:$B$26)>0))*((1*ROW($B$1:$B$26)0,IF(ABS(A2-INDIRECT("A"&LARGE(IF((1*(LEN($B$1:$B$26)>0))ROW($B$1:$B$26)>0,(ROW($B$1:$B$26)=$K$1,ROW(A2),""),"")
ANOTHER EDIT: Instead, close this formula with ctrl+shift+enter in C2 cell and pull down till the last
=IF(B2<>"",IF(INDIRECT("B"&SMALL(IFERROR(IF(LEN(B3:$B$26)>0,ROW(B3:$B$26),""),""),1))<>B2,B2,""),"")
Third step - Arrange data in a list. This is what in your image is in columns D and E. Use these formulas in the first row of any column you want, and pull down as you wish since non utilized cells will just be blank
=IFERROR(SMALL($C$1:$C$26,ROW(C1)),"")
and
=IFERROR(INDEX($C$1:$C$26,E1),"")
EDIT: now use these formulas below to have the ordered list of changes
=IFERROR(SMALL(IF(LEN($C$1:$C$26)>0,ROW($C$1:$C$26),""),ROW(A1)),"")
and
=IFERROR(INDEX(C:C, F1),"")
As I've put the first of these two formulas on F1 (and pulled down), the second is using F1 as a parameter, but you can put any column you want, just don't forget to change in the index. The first of these two formulas also need to be closed with ctrl+shift+enter, the second doesn't.
This is how my sheet looks right now (with last changes)
OBS: Italic parts are "deprecated" in this answer. Only maintaining the text for "log" purposes.
The first of these two formulas use ROW() as a scapegoat for the number of SMALL's "K" parameter, so you pull down and it will return the first, the second, third, etc, trend changer rows. The other one will pull the matching "up" or "down" information.
OBS: since my Excel is in portuguese and I translated the functions to english using some web dictionary, I may have made some mistakes such as letting semicolon as parameter separators rather than commas. If something goes wrong please let me know and I'll try to fix it.

Count consecutive instances in column

I am tracking my days on duty and want excel to count the number of consecutive days on duty and post the totals next to the current date. I managed to insert a formula that does this but it counts in reverse order. In the attached image of the file note that on 6/13/2018 it shows 28 continuous days on duty. But that is counted from 7/10/2018 back. I want that 28 to show up on 7/10/2018. So that it counts from the previous days to the current day. Make sense????
What do I need to change in the formula to do this? Formula can be seen in the image.
Any suggestions would be appreciated
You need to build your formula the other way around:
If row r-1 has the same status as row r, then Counter_r should be Counter_(r-1) + 1. Otherwise, restart the counter - and Counter_r = 1
So, for example, in cell E3 the formula should be:
=IF(D3=D2, E2+1, 1)
I guess the picture helps a bit, but I would have preferred to see the data, even though this is simple enough to reproduce.
You probably want the formula:
=IF(AND(D2="On Duty",D2=D1),E1+1,1)
Starting in Cell E2 and copied down from there.

Getting minutes between different dates in excel

I'm trying to calculate the time between the dates , at the beginning the formula
was working fine but I've noticed that it does not work when the date is different
For example , I have the following information on cell A1: 09/15/2016 10:00 AM
On Cell B2 I have: 09/16/2016 10:00 AM
The formula is just B2-A1 but instead of giving me a result of 24 hours is just giving me 0 . I believe the formula is not recognizing that these are 2 different days and is just doing 10-10
Any idea how to fix this ?
I was able to get the result 24 by setting a custom format of [h] (you will have to type it into the 'Type:' box) on cell C1 while using the formula =B1-A1
Excel Reference
'Format Cells' view
The problem with just using =B1-A1 is that if either or both of those cells is not populated then you will get weird numbers in C1. You may want to make C1 display as a blank cell unless both boxes are populated, try something like this =IF(OR(ISBLANK(A1),ISBLANK(B1)),"",B1-A1)
The reason for the weird numbers is that Excel calculates time based on a predefined decimal system that indexes time starting at like 1/1/1900 or something like that. So when manipulating or calculating time, that is something that you always have to keep in the back of your mind.
Hope this helps.
Formation the destination cell to will do but since you have date and time combined it will show as 1 calendar day difference 0 only means that 12 am after the 1 day difference, I know it does not make any sense but its Excel...
If I was you, on column A, I would add the date, and on Column B, the time.
then just work with the time, as both combined can be tricky
Don't forget to format your cells!! (right click>Format Cells>Time>3/14/12 1:30 PM)

How to use 2 cells values to create the name of a table you wish to look extract a value from

EDIT *
A JAN FEB MAR APR
1<drpdwn> A1+JAN A1+FEB A1+MAR A1+APR
what i need is for B1 to hold a formula that will take A1+B as a string and use this as the name of a Table to grab a value from. so something like
=INDIRECT($A1&"B")[[#Totals],[Column7]] so the cell will display the value in column 7 in the totals row for a table that is named the result of '=INDIRECT($A1&"C")' =B2&A3 also works for creating the variable, but again. unable to use in the above formula
Hopefully this is a little bit clearer
As an example, I will have 12 tabs that lets say are months, JAN FEB MAR etc... these are the column headers in my above.
Within these will be various Tables, like Expenditure, income, etc... they will be named ExpenditureJAN, ExpenditureFEB.
I want a simple (overview) tab, that lets me select expenditure in A1, and each months columns will use the formula to display a value from its relevant table, so A(JAN) would display jan's expenditure total etc.....
=ExpenditureJAN[[#Totals],[Column7]] this would work, but i need the expenditure bit, to change to what ever is selected from a picklist in A1.
***Old Question - Before edit -
Didn't know how to word the question, but here is my problem;
I have tables called AB, AC, AD, BB, BC etc...
I want to look up the following =AB[[#Totals],[Column7]] which works fine. However.....
I want it to change AB to be the string created from two cells so for instance =A3&B2[[#Totals],[Column7]]
Hopefully that makes sense, i am struggling to put this into words for some reason.... To add to this, A3 will be a drop down list, so the idea is, i change the value in A3 and it will change the table each cell the formula is in to look at the correct value.
B C D E
# #B #C #D #E
So # can change via a picklist, and the formula will detect this change and fire off to look at #totals, column 7 in the table #B/#C etc.. using the column headers and picklist as references for the table name.*
As user3514930 stated you want to use the INDIRECT function. Given the following table:
A B C D E
1<drpdwn> #B #C #D #E
If Cell B1 contains the formula =INDIRECT($A1&"B") it would show whatever is selected in cell A1 immediately followed by the character B. So drag that over to fill the rest of the row and update the trailing letter to =INDIRECT($A1&"C"), =INDIRECT($A1&"D"), =INDIRECT($A1&"E") etc. in the formulas.
Then when the dropdown box in cell A1 is changed, say to C the table would look like this:
A B C D E
1 C CB CC CD CE
Edit: So I got this to work like you wanted using INDEX, INDIRECT, and an additional cell to reference the table desired. I setup a table like you suggested named ExpendituresJAN. It had 6 columns, first was Week1-Week4, then HR, IT, Admin, Sales, and Payroll for departments, and then Column7 where I had totals per week. I threw in some random numbers (IT had a heck a week 3, spending nearly $997k evidently, and the sales department outdid itself with it's end of month party running over $10k, but those boys do love to party!). Sorry, where was I? Oh yes, example table, I added a Totals row on, and went to trying to figure it out because INDIRECT really seemed to be the key and I just had to wrap my head around things.
Next sheet had basically 4 cells with anything in them. A2 had a dropdown where I could Choose JAN, FEB, or MAR. B1 said JAN (I imagine C1 would say FEB, but I didn't go that far). B2 said #REF! a lot of the time.
________| JAN
<drpdwn>| #REF!
In the end A2 was moved down to A3 for my dropdown box, and row 2 was hidden, I'll get to why that is in a second. Ok, how to reference that... I can't seem to do it traditionally with structured reference, which is a pain, but there's got to be a way around it. I crack my knuckles, pull up Chrome, and practice a little Google-fu. Turns out what we needed was INDEX, which will return a cell or range from a table by name. B2 (hidden now) now contains the formula ="Expenditures"&A3 which, when JAN was selected read ExpendituresJAN. Excellent, I'm pretty sure we're most of the way there now. I just have to phrase my INDEX right and I'm set.
So, INDEX ended up being relatively simple all in all, but there's a catch. No #Totals row accessibility for INDEX. I got hung up on that for a few minutes until I stepped back and thought "wait, what's my totals row except a =SUM() formula? Ok, I can duplicate that. INDEX works with this syntax: INDEX(array/table, Row#, Col#) but you can use 0 for the row and it takes the entire row into account. Perfect for what I want, since I want a sum of Column7, I'll just wrap the INDEX in a SUM function.
=SUM(INDEX(INDIRECT(B2),0,7))
That spits back $1,036,371.00, the exact same thing my totals row shows for Column7. The only complication I could see is if your different tables have different Totals rows, as in one does a SUM, one does an AVG, and what not. Then the formula starts getting a bit more complex.

Need help with formula on 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

Resources