I have a excel spreadsheet with two columns. One with a date and another with the value.
I want to get the working day of the month with the lowest value.
I tried to use a pivot table for it and then group the date but I get a lot of errors.
You can find the spreadsheet here and the sheet name is Historical. The others are just attempts made by me.
Spreadsheet
Thanks
The formula entered in E2 below
is
=AGGREGATE(15,6,(POWER(10,LOG10(((YEAR(D2)=YEAR($A$2:$A$3254))*(MONTH(D2)=MONTH($A$2:$A$3254)))))*$B$2:$B$3254),1)
and the array formula entered in F2 below is
=INDEX($A$2:$A$3254,MATCH(YEAR(D2)&MONTH(D2)&E2,YEAR($A$2:$A$3254)&MONTH($A$2:$A$3254)&$B$2:$B$3254,0))
I suggest to make an triple nested if-construct that checks if the weekday of the date is a workday, or the date+ 1 or the day +2. Assuming the date is in cell A4
= if(instr(weekday(A4),”23456”)>0, A4,
if(instr(weekday(A4+1),”23456”)>0, A4 + 1,
if(instr(weekday(A4+2),”23456”)>0, A4 + 2,”cannot happen”)))
Explanation: one of 3 consecutive days is always a working day.
There may be typos since I edit that on iPad without Excel available to test.
Weekday returns 1 for Sunday and 7 for Saturday. So 2-6 are workdays.
However with that simple approach you will not detect public holidays on a working day if that is a problem.
Hope I understood you question correctly. One data example with solution would have explained it better.
Related
So I have a problem that I'm dealing with for days now and I cant figure it out. I have this problem in excel, I am looking for assistance regarding a calculation. I want to be able to calculate a payment date schedule based on a set monthly payment date but to exclude exclude weekends and specific holiday dates e.g.
Here's My file I'm Working on:[].
Here is some function that I already used : =IF(TEXT(O2,"dddd")=$U$2,O2+2,IF(TEXT(O2,"dddd")=$U$3,O2+1,O2))This works for only weekends, It doesn't work on holidays, I want it to work not only on weekends and on holidays too.
Thanks in advance.
This can be done by using the WORKDAY() function together with the DATE() function.
B2 contains year - 2012
B3 contains payment day - 28
A5:A17 contain payment periods (month numbers) - 1..12
D6:D16 contain holidays
=WORKDAY(DATE($B$2,A6,$B$3-1),1,$D$6:$D$14)
Also see the linked image. (NB: My Excel version uses semi-colon ";" in stead of comma "," to separate arguments in functions.)
Best of luck!
Xharx
Image of the Excel sheet solution
Here's How u Do it. First we have to have starting month from where were gonna start counting I made this formula which works great, =WORKDAY(EDATE($B$15,COUNT($B$15:B17))-1,1,holiday1)
were freezing the starting date and counting how many rows are we from the starting position , then were gonna minus 1 from it , and in days were gonna type 1, if there's holidays that I wanna exclude too I just can enter it and give it a name, (Some of u who doesn't understand this, its just saying that its referring to specified cells which we named holidays) and it works flawlessly.
B15 = starting month
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)
I am somewhat new to writing large, complicated formulas with excel. I took over a report from someone about 7 months ago and it seems that every week I find issues with what was written with his formulas.
This week I am having issues with a match formula. We have a report we run for a big hardware store and they report based on weeks. This last week was 201501 (2015, week 1.) Last week was 201452 (2014, week 52.)
To look at 4 week sales averages, my predecessor setup 4 numbers that would change every week based on the week you type in one of the column headings. So, when I type 201452,
#1 is 201449
#2 is 201450
#3 is 201451
#4 is 201452
He feeds those into a match function.
I found this week that 201501 does not correctly display the weeks. I got
Results Formula Used
201501 =D1 (The cell where you type the Store's week)
201500 =IF(M1=201301,201252,IF(M1=201401,201352,M1-1))
201499 =IF(L1=201301,201252,IF(L1=201401,201352,L1-1))
201498 =IF(K1=201301,201252,IF(K1=201401,201352,K1-1))
I changed those formulas
Results New Formula
201501 =D1
201452 =IF(RIGHT(M1,2) = "01",(LEFT(M1,4) - 1)&"52",M1-1)
201451 =IF(RIGHT(L1,2) = "01",(LEFT(L1,4) - 1)&"52",L1-1)
201450 =IF(RIGHT(K1,2) = "01",(LEFT(K1,4) - 1)&"52",K1-1)
However, the match formulas he has setup throughout the workbook have not been fixed. They are still displaying "#N/A." One such formula is
=INDEX(N5:DZ5,1,MATCH(Data!$L$1,$N$1:$ED$1,0))
This formula basically looks at the column headers, and if it sees that the column header matches the week I've typed, will display the value within that range.
Basically, any formula that's being fed the 201452 value is returning "#N/A". The other numbers miraculously display data.
I've already tried converting all of my data in the affected rows to "General" format type. I've tried checking to see if I have spaces before or after in all of my formulas and column headers, but am still having no luck.
Any ideas?
After trying and trying and trying, I found that Excel does not like the concatenation. Trim does not help, Text does not help, Concatenate of course did not work.
I ended up realizing I could simply write
=IF(RIGHT(M1,2) = "01",M1-49,M1-1)
This makes it so that in the instance where the number to the right of it is the first week, subtract 49 days and produce 52 instead of 00.
I'm guessing here, but it could be that your formulas are presenting the Year/Week combo as a number, where the Match formula is looking for text (for Excel's purpose, it doesn't recognize them as the same).
You can get around this, by wrapping your formulas above with the text formula
So you'd have the following:
Results New Formula
201501 =TEXT(D1,"0")
201452 =TEXT(IF(RIGHT(M1,2) = "01",(LEFT(M1,4) - 1)&"52",M1-1),"0")
201451 =TEXT(IF(RIGHT(L1,2) = "01",(LEFT(L1,4) - 1)&"52",L1-1),"0")
201450 =TEXT(IF(RIGHT(K1,2) = "01",(LEFT(K1,4) - 1)&"52",K1-1),"0")
Have a few different items with different rental periods ( 1,3,6 months to 1,3,5 years). As it stands I have a column with the last renewal date and a column indicating what is the renewal period. I wanted excel to calculate what the Renewal date would be based on the selected type of renewal. My first attempt was to convert the renewal types to some kinda of similar denomination but i got stuck trying to figure out what value/format to use.
Last renewal date Renewal Type Renewal Date
11/11/2013 1 Year
2/14/2014 2 Years
8/28/2011 5 Years
11/27/2013 3 Months
[Excel stores dates as floating point numbers. They advance by 1 each day and the fractional part holds the day fraction, e.g. 0.5 is midday. The exact value is user-configurable between 1900 and 1904 origins which can complicate things. Note that in the 1900 origin, date 60 (corresponding to the non-existent date 29-Feb-1900) is defined. Leap seconds are not implemented.]
If you can tolerate the second column being integral months, then use the EDATE function.
For example, if your table is orientated on cell A1, use
=EDATE(A2, B2) in cell C2 and copy downwards.
I would use a Vlookup in the third column which should point to a table which has conversion of 1 year/6mos into days. (365,180, ect). Then just add that vlookup to the original date.
So
`TblDate
Lookup Days
1mo 30
.. ..`
=VLOOKUP(B1,TblDate,2,FALSE)+A1
Maybe try:
=IF(ISERROR(FIND("year",B2)),DATE(YEAR(A2),MONTH(A2)+LEFT(B2,1),DAY(A2)),DATE(YEAR(A2)+LEFT(B2,1),MONTH(A2),DAY(A2)))
In D2 enter:
=--MID(B2,1,FIND(" ",B2))
and copy down
In E2 enter:
=MID(B2,FIND(" ",B2)+1,1)
and copy down
Finally in C2 enter:
=IF(E2="Y",DATE(YEAR(A2)+D2,MONTH(A2),DAY(A2)),DATE(YEAR(A2),MONTH(A2)+D2,DAY(A2)))
Format C2 as Date and copy down. For example:
.
.
There is a way to convert your second column into pure month format, using Excel:
=IF(COUNTIF(B2,"*Year*"),(TRIM(LEFT(B2,2)))*12,IF(COUNTIF(B2,"*Month*"),TRIM(LEFT(B2,2)),NA()))
This can then be used with EDATE(). For example, lets say that the above code is in cell C2, it would produce 12. Then, you could in cell D2, you could put
EDATE(A2,C2)
in there. The code works for anything between 1 month and 99 years and doesn't care whether the first number is one or two digits and whether the word is month, months, year or years - it will work with all of it, as TRIM() removes whitespace (thus allowing for one character and a space or two characters) and * is a wildcard (hence allowing x years or xz year).
For EDATE to work you need to make sure the number format is set to date type.
Note: an extra cell for the months will be needed - so it might require a little rearranging, but using CTRL+C or copy cells tool in the bottom right of a selected cell will easily copy it, and for each one it will automatically convert it.
create a new column and type in the formaula box
=B2+1095
to get your renewal date
1 year is 365
2 years is 730
3 years is 1095
and so on and so forth.
this was the most simple way and worked for me!
Program: Excel 2010
Experience Level: Basic
Hi there,
I am creating an Invoice which pulls data in from other sheets via VLOOKUP, the page is full of formulas and code (which I'm happy with), however I am having an issue when it comes to setting a date.
The issue:
When I use the formula to get my "1st Tues of the following Month" referencing cell (F3) the formula does not work. The date in (F3) has been generated by a VLOOKUP, so I believe my new formula is erroring out because it doesn't have a "Date", just a result of code.
Here are my formulas:
Cell(F3) =IF(TEXT(VLOOKUP($F$2,OrdSum,24,FALSE),"mmm-dd-yyyy")="","",(TEXT(VLOOKUP($F$2,OrdSum,24,FALSE),"mmm-dd-yyyy")))
Results: Jan-31-2014 (It is pulling the last day of the sales month which I manually write in every month from my OrdSum, I don't want it dynamic).
Cell(A14) =((EOMONTH(F3,0)+1)+7)+CHOOSE(WEEKDAY((EOMONTH(F3,0)+1)),2,1,0,6,5,4,3)
Results: #VALUE!
However if I have a hardcoded date in any cell the formula works and returns 11/02/2014
.
Even a simple =EOMONTH(F3,1) does not work, it results in the #VALUE! error.
Is there a workaround? Or do I have to write in the EOM manually on the Invoice as well.
Thanks in advance.
If the VLOOKUP is already pulling a date, you don't really need the TEXT part (you don't need it since if the VLOOKUP returns a blank, TEXT will convert it to 00-01-1900 anyway), this should suffice:
=IF(VLOOKUP($F$2,OrdSum,24,FALSE)="","",VLOOKUP($F$2,OrdSum,24,FALSE))
For cell F3. You only need to format F3 as mmm-dd-yyyy through custom formatting or date formatting.
EDIT: #Barryhoudini had a simpler formula for the 2nd Tuesday of the month. credit goes to him for this, I'm just elaborating a bit more here:
=EOMONTH(F3,0)+15-WEEKDAY(EOMONTH(F3,0)+5)
Will give the date of the 2nd Tuesday of the month. The last 5 is what determines what day of the week it is. You could perhaps re-write it like this to make it simpler:
=EOMONTH(F3,0)+15-WEEKDAY(EOMONTH(F3,0)+(7-3))
Where 3 is Wednesday. You can change the last number to mean these:
0 or 7 Sunday
1 Monday
2 Tuesday
3 Wednesday
4 Thursday
5 Friday
6 Saturday
The following formula, at the expense of some verbosity, does away with the VLOOKUP (which always makes spreadsheets brittle), and any formatting considerations.
If cell A1 contains a date, then
=1 + EOMONTH(A1,0) + MOD(3 - WEEKDAY(1 + EOMONTH(A1,0)),7)
returns a date that is the first Tuesday of the following month. Tuesday has a weekday value of 3 which is why this literal appears as the first term in the MOD(.
If you wanted to centre on, say Thursday (which has a weekday value of 5), then write
=1 + EOMONTH(A1,0) + MOD(5 - WEEKDAY(1 + EOMONTH(A1,0)),7)