I was hoping someone could help me out with and If/Then formula:
I need a formula that will tell me if a birth date that is entered in Cell B3 is between the age 12-24 months of age in the years 8/01/2009 to 12/31/2012. For Example, someone who was born 11/01/2008 was between 12-24 months in the years 2009-2012 therefore the value should return a YES in Cell D4. If the child was under 12 months or over 24 months the Cell value will be no.
Also in Cell D4 a value should return a Yes if in Cell B3 and Cell B4 has two birth dates and both were under 6 years old in the years 8/01/2009 up to 12/31/2012. For Example, in cell B3 the birth date was entered 11/1/2005 and in cell B4 the birth date that was entered is 8/1/2004 so the Value in cell D4 should be yes. If both children were not under 6 years old then the cell value will be No.
Hopefully someone can help me out,
Thank you
Before creating the Excel formula, you first simplify the problem by doing a bit of math.
The youngest child to fall in the date range would be exactly 12 months old on 12/31/2012, so would have a birthdate of 12/31/2011.
The oldest child in the date range would be exactly 24 months old on 8/01/2009, with a birthdate of 8/01/2007.
This formula will check for a date in a certain range:
=IF(AND(B3>=DATE(2007,8,1),B3<=DATE(2011,12,31)),"Yes","No")
You need to double-check your boundary conditions. For instance, if the child has a 1st birthday exactly on 8/01/2009 do you still want to include them? If not, change >= to >.
The second problem is also an AND'ing of four date comparisons, which you can now work out.
The only tricky thing is when B3 or B4 are blank. With date comparisons, blank or 0 are equivalent to 12/31/1899. That will give a current age of over 100 years old, which will fail the age test.
I think I've got a solution that solves what I understand your problem to be. I used B6 and B7 to hold the years for your range. B6 has 2009 in it, and B7 has 2012 entered in it.
=IF(B4="",IF(AND((DATE(B6,1,1)-B3)/30<=12,(DATE(B7,1,1)-B3)/30>=24),"Yes","No"),IF(AND((DATE(B7,1,1)-B3)/30>=72,(DATE(B7,1,1)-B4)/30>=72),"Yes","No"))
Breaking it down a bit:
Test to see if there is a date in B4
=IF(B4=""
If not, then we need to see if the child was less than 12 months old at the beginning of the period AND greater than 24 months at the end of the period. (using AND lets us make sure that the child turned 12 months after the start and 24 months before the end)
IF(AND((DATE(B6,1,1)-B3)/30<=12,(DATE(B7,1,1)-B3)/30>=24),"Yes","No")
If there are 2 dates, then check to see if both children were less than 72 months by the end date (B7).
IF(AND((DATE(B7,1,1)-B3)/30>=72,(DATE(B7,1,1)-B4)/30>=72),"Yes","No")
Excel recognizes the date as a numerical value. Below are my defined date ranges. I needed to develop something that would reference different VLOOKUP data based on date range criteria. This can be utilized all in one big formula and you just add as you go depending on your needs. Plenty of ways to probably write this.
Here is another way:
"=IF(ISBLANK(C[-7]),""""," & _
"IF(AND(C[-7]>=42571,C[-7]<=42572),(VLOOKUP(C[9],'C:\Users\etabakman\Desktop\[BillNet Master List - current.xlsx]07-20-2016'!C39:C41,2,FALSE))," & _
"IF(AND(C[-7]>=42573,C[-7]<=42582),(VLOOKUP(C[9],'C:\Users\etabakman\Desktop\[BillNet Master List - current.xlsx]07-22-2016'!C39:C41,2,FALSE))," & _
"IF(AND(C[-7]>=42583,C[-7]<=42586),(VLOOKUP(C[9],'C:\Users\etabakman\Desktop\[BillNet Master List - current.xlsx]08-01-2016'!C39:C41,2,FALSE))," & _
"IF(AND(C[-7]>=42587,C[-7]<=42593),(VLOOKUP(C[9],'C:\Users\etabakman\Desktop\[BillNet Master List - current.xlsx]08-05-2016 V2'!C39:C41,2,FALSE))," & _
"IF(AND(C[-7]>=42594,C[-7]<=42735),(VLOOKUP(C[9],'C:\Users\etabakman\Desktop\[BillNet Master List - current.xlsx]BillNet Master list'!C39:C41,2,FALSE))))))))"
Related
I have two columns in excel, one with a date and one with a rating 'low, medium, high'.
I'm trying to write a formula to put in a third column that checks:
If A2 = Low and B2 (date) is older than 12 months from today(), output Overdue
If A2 = Medium and B2 (date) is older than 6 months from today(), output Overdue
If A2 = High and B2 (date) is older than 3 months from today(), output Overdue
If these parameters aren't met, output "Current".
This is what I have so far but I'm well aware its not right :)
Could someone please point me in the right direction?
Thanks,
=IF(AND(A2="Low",LOOKUP(DATEDIF(B2,TODAY(),"m"),{0,3,6,12},{"Current", "Current" "Current","Overdue"}),(A2="Medium",LOOKUP(DATEDIF(B2,TODAY(),"m"),{0,3,6,12},{"Current","Current","Overdue","Overdue"}),(A2="High",LOOKUP(DATEDIF(B2,TODAY(),"m"),{0,3,6,12},{"Current","Overdue","Overdue","Overdue"})
If you can use the excel 365 then I’d suggest creating an excel lambda function:
=LAMBDA(level, date, LET(months, IFS(level="Low",12,level="Medium",6,level="High",3,TRUE,0), IF(date < EDATE(Today(), -months),"Overdue", "Current")))
so to break it down, this is a custom function that expects 2 parameters :
level is the value/reference that has low/medium/high. this is used to determine the number of months for the threshold - 12/6/3 respectively and 0 for anything else though you could change that as needed.
date is the date to check if its beyond the threshold. this is compared against today minus the number of months calculated from the level. if this is before that date then this function will return “Overdue”. otherwise “Current”.
You would create a workbook level named reference with this function as the value.
Here I named it IsCurrent. Then you just use that function where you want the output. e.g.
What I would suggest is to "outsource" the settings for the overdue months.
This is a good habit, as everyone looking at the table can see those settings and propably adjust them - without going into the formula.
And it is possible to use these settings in another formula :-)
If you use Excel 365 you can make the formula more readable/understandable with the LET-Formula.
=LET( OverdueMonthsForRating, IFNA(INDEX(configOverdue[Overdue months],MATCH([#Rating],configOverdue[Rating],0)),0), OverdueDate,IF(OverdueMonthsForRating>0, EDATE([#Date],OverdueMonthsForRating),TODAY()), IF(OverdueDate<TODAY(),"overdue","current") )
OverdueMonthsForRating is using a classic INDEX/MATCH to retrieve the number of months according to the Rating. In case Rating is not found 0 is returned
OverdueDate calculates - using EDATE - the overdue date based on the ratings date and OverdueMonthsForRating. In case Rating is not found TODAY is returned
Finally this date is evaluated against TODAY and the status is returned.
Classic Excel formula w/o LET:
=IF(EDATE([#Date],IFNA(INDEX(configOverdue[Overdue months],MATCH([#Rating],configOverdue[Rating],0)),TODAY()))<TODAY(),"overdue","current")
I need to recreate some of the functionality from Excel's EOMONTH function -- specifically the ability to enter a date and an integer representing a number of months in the future or past, and from those inputs calculate a new date that is the last day of the target month. I have been using Excel formulas for some simple testing and I can get close but cannot get it exactly right. So I would like to do this in Excel but without using the EOMONTH function or any of the other fancy date-related functions like EDATE or DATE or similar (because some of these automatically handle / correct some kinds of invalid data ... like months larger than 12 for example). TRUNC and MOD are fine ... and basic math operators ... but that's about it. This needs to be done in excel only -- no VBA code. We can assume the date entered is a month-end date, if that helps.
Say I have the following data in cells:
A1: 12/31/2021
A2: 1
The result in A3 or wherever should be 1/31/2022
With A1: 12/31/2021
A2: 0
A3 should be 12/31/21
A1: 12/31/2021
A2: -1
A3 should be 11/30/2021
A1: 12/31/2021
A2: -12
A3 should be 12/31/2020
I need to go up to 60 months forward or backward from any valid end-of-month date. I have been able to do what I want with a positive number (or zero) in A2, but negative numbers cause issues which I have not been able to figure out. I am using MOD + TRUNC + some basic math inside IF statements -- pretty ugly and doesn't handle negative numbers so I'm hoping there is a better way. Oh ... and I have actually been deriving Day 1 of the month following my "target month" ... and then subtracting 1 from that Day 1 date, to arrive at my target End Of Month date. This seems to me like a good way to work around the (lack of) EOMONTH function ... but I am happy to entertain any and all ideas / options.
--- New Info added 12/23 ---
I cannot simply use the EOMONTH formula because my target language (a virtual attribute in Uniquery) does not support it. So I am prototyping the solution in Excel but will implement it in the other system.
I did not include the detail below initially because A) I think there must be a more elegant solution so I am a little embarrassed about this ugliness and B) it is a lot of detail which I thought might be unnecessary. But since you asked :) here is some data from my worksheet showing what I have done and the results (and the issue).
Input:
A3 (input date): 10/15/2020
E3 (Months +/-): *** see comments below ***
Formulas:
B3 (input month): =MONTH(A3)
D3 (input Year): =YEAR(A3)
G3 (Interim New Month): =B3+E3+1 (+1 to give me the month AFTER my target month)
H3 (Month Adjustment): =MOD(G3,12)
I3 (Year Adjustment): =TRUNC(G3/12,0)
J3 (New Month): =IF(H3=0,12,H3)
K3 (New Year): =IF(H3=0,D3+I3-1,D3+I3)
L3 (Interim New Date): =J3&"/1/"&K3 (This will be day after my target date)
M3 (New / Target Date): DATEVALUE(L3)-1
With a couple dozen dates in cells A3:A27, first date = 10/15/2020, second date = 11/15/202, etc. (each date in the following month) ... and the formulas above entered on row 3 then copy/pasted down to row 27 ... and trying various values in cell E3 ... I can see the formulas work for numbers from -2 up through +60, but fail for certain months when E3 contains -3 or smaller. Specifically, with E3=-3 and input date = 1/15/21 my logic fails because the Interim New Month (column G) calculates a value of -1 which causes problems for the downstream formulas. I have addressed some of these problems with the MOD and TRUNC logic ... and the IF H3=0 logic ... but the one thing I cannot figure out is how to get the year right. With the current formulas when E3 is -3 and the base date is 1/15/21 the final year comes out 2021 which is incorrect. It should be 2020. And when E3 = -4 the base dates of 1/15/21 and 2/15/21 both produce incorrect values for Year -- 2021 instead of 2020. Smaller and Smaller E3 values produce more incorrect results.
Surely there is a relatively easy solution to this but I just cannot see it!?!?
Thanks!
I am making an on-call schedule in excel and I can't for the life of me find an easy way to populate the dates. For example, someone is on call from Monday to Sunday, January 2nd - January 8th. Then the next person is on call from January 9th - January 15th. I am trying to figure out a way or formula to just "Drag" down the column and it input the next 7 day range. I have tried input the start date and end date in a separate cell, then using concatenate but it returns the date number in excel (forgot what its called). I also tried =(A1&" - "&B1) but that returns the same 5 digit number.
Any help or pointers are greatly appreciated!
Previous date + 7
If you have genuine dates, say in cells A1 "start date" and B1 "end date":
Jan 2 Jan 8
Then the next line will be
=A1+7 =B1+7
Verify Dates
To see, if the "Dates" you entered are realy dates excel can work with like that, apply "General formatting" to the A1 and B1 cells. If the resulting value is an Interer or a Decimal number, you are golden. If the resulting value did not change, you have a text and you need to apply different approach.
Perhaps you are looking for this:
=TEXT(A1,"d-mmm")&" - "&TEXT(B1,"d-mmm")
The formatting specification can be copied from the formatted cell properties.
I'm looking for a formula which allows me to look at a cell and check if it greater than or equal to today's date and to return a worded result such as "overdue". If it is blank to return another word, or nothing.
I have tried copying the result from the source cell (O10) into another cell (Y10) and used an if statement but this seems overly laborious - there must be a way to read the information from the source cell? See below. It also returns overdue when the cell is blank :(
=IF(O10>Y10,"OVERDUE","NOT DUE")
You can enter the following formula in the cell where you want to see the Overdue or Not due result:
=IF(ISBLANK(O10),"",IF(O10<TODAY(),"Overdue","Not due"))
This formula first tests if the source cell is blank. If it is, then the result cell will be filled with the empty string. If the source is not blank, then the formula tests if the date in the source cell is before the current day. If it is, then the value is set to Overdue, otherwise it is set to Not due.
I think this will cover any possible scenario for what is in O10:
=IF(ISBLANK(O10),"",IF(O10<TODAY(),IF(TODAY()-O10<>1,CONCATENATE("Due in ",TEXT(TODAY()-O10,"d")," days"),CONCATENATE("Due in ",TEXT(TODAY()-O10,"d")," day")),IF(O10=TODAY(),"Due Today","Overdue")))
For Dates that are before Today, it will tell you how many days the item is due in. If O10 = Today then it will say "Due Today". Anything past Today and it will read overdue. Lastly, if it is blank, the cell will also appear blank. Let me know what you think!
The formula provided by Blake doesn't seem to work for me. For past dates it returns due in xx days and for future dates, it returns overdue. Also, it will only return 15 days overdue, when it could actually be 30, 60 90+.
I created this, which seems to work and provides 'Due in xx days', 'Overdue xx days' and 'Due Today'.
=IF(ISBLANK(O10),"",IF(DAYS(TODAY(),O10)<0,CONCATENATE("Due in ",-DAYS(TODAY(),O10)," Days"),IF(DAYS(TODAY(),O10)>0,CONCATENATE("Overdue ",DAYS(TODAY(),O10)," Days"),"Due Today")))
My problem is the following...
I have a little aeroplane and I need to track the hours. I have to track the hours by sectors and not the total of the day (that's why sometimes I have 2 or 3 on the same day).
Now this is the problem... On column C I need to SUM the hours of the last 7 days. And any given 7 days, not just last week. To do it manually is quite easy... the problem is that I need a formula as my records are quite large...
Here with a small example (let's say that there was NO HOURS before 15/01/2009)...
COLUMN A-------COLUMN B-------COLUMN C
DATE--------------HOURS-------HOURS LAST 7 DAYS
15/01/2009-------01:00-------01:00
15/01/2009-------02:15-------03:15
16/01/2009-------01:15-------04:30
17/01/2009-------01:30-------06:00
18/01/2009-------01:30-------07:30
18/01/2009-------01:00-------08:30
18/01/2009-------02:00-------10:30
19/01/2009-------02:30-------13:00
19/01/2009-------03:00-------16:00
20/01/2009-------////////--------16:00
21/01/2009-------01:00-------17:00
22/01/2009-------01:30-------15:15
23/01/2009-------02:00-------16:00
I've been fighting for the last weeks trying to figure out a formula but no luck... any suggestions?
Thanks
Another solution that basically does much the same as the earlier offered solutions:
In C1, enter the following formula:
{=SUM(IF(($A$1:$A1>=($A1-6))*($A$1:$A1<=$A1), $B$1:$B1, 0))}
And then just drag the formula down.
If you're not familiar with array formulas, the {} outer brackets just indicate that the formula is an array formula. To get it to execute correctly, you need to copy the part inside the {} brackets into the formula bar, and then hit Ctrl+Shift+Enter to indicate that it's an array formula.
First thing is to get the begin date, which would be the following function:
=Now() - 7
If you renamed that cell to "WeekBegin", then you could use the following formula to calculate the total hours:
=SUMIF(A:A,">=" & WeekBegin,B:B)
Notice that I used column references; this was to both simplify the formula, but also allow you to add new data to the end of the range easily. You will need to take care that your WeekBegin cell is not in that column A or column B, otherwise you'll get a circular reference warning.
If you planned to have numeric data above or below your input range, you would need to explicitly call out the sum and criteria ranges as follows:
=SUMIF(A2:A14,">=" & WeekBegin,B2:B14)
Additionally, you may find that your result comes up initially as a decimal. That's Excel's date serial format, so you may need to format your result as time.
Hope that helps!
[Edit: On second pass, if you're looking to sum a range based on a from and to date (so any 7 days as you seem to imply in your post), look for the previous poster's note, i.e.:
=SUM(B:B) - SUMIF(A:A, "<="& BeginDate, B:B) - SUMIF(A:A, ">"& EndDate, B:B)
A more elegant solution is offered in Excel 2007 using the SumIFS() function:
=SUMIFS(B:B, A:A, ">=" & FromDate,A:A, "<" & ToDate)
Note that the arguments for SUMIFS are in a different order than the standard SUMIF.
Happy Summing!]
Here's the data in better format if someone wants to try:
15-Jan-2009 01:00
15-Jan-2009 02:15
16-Jan-2009 01:15
17-Jan-2009 01:30
18-Jan-2009 01:30
18-Jan-2009 01:10
18-Jan-2009 02:00
19-Jan-2009 02:30
19-Jan-2009 03:00
20-Jan-2009
21-Jan-2009 01:00
22-Jan-2009 01:30
23-Jan-2009 02:00
I got the function:
=SUM($B$1:$B$13)-SUMIF($A$1:$A$13, "<="& (A1- 7), $B$1:$B$13) - SUMIF($A$1:$A$13, ">"& (A1), $B$1:$B$13)
This was based on Sum of named ranges conditional to date?.
The idea is to first compute the total sum: SUM($B$1:$B$13)
then subtract any values that happened older than 7 days ago: SUMIF($A$1:$A$13, "<="& (A1- 7), $B$1:$B$13)
then subtract any values that happened in the future: SUMIF($A$1:$A$13, ">"& (A1), $B$1:$B$13)
The point is to use SUMIF function, which "adds the cells specified by a given criteria."