Related
I am trying to create an Excel formula that will display someone's age in units of days, weeks, months, or years, depending on how old they were at the time of a test. To clarify...
If younger than 7 days, report the age in days
If older than 7 days but younger than 8 weeks, report the age in weeks
If older than 8 weeks but younger than 24 months, report the age in months
If older than 24 months, report the age in years
I have tried several functions for this, all using the DATEDIF function. For each, I have returned the #NAME? error. Please see below
KEY:
E600 = Date of Test
F600 = Date of Birth
I am using 7 days = 1 week, 60 days = 2 months, 730 days = 24 months = 2 years, etc.
Note: I also want to display "d/o" (days old), "w/o" (weeks old), "m/o" (months old), or "y/o" (years old) after each value, depending on the units that age is being reported in.
\\\\\\\\\\\\
=IFS((E600-F600)<7,DATEDIF(F600,E600,”d”)&” d/o”,AND((E600-F600)>7,(E600-F600)<60),(DATEDIF(F600,E600,”d”)/7)&” w/o”,AND((E600-F600)>60,(E600-F600)<730),DATEDIF(F600,E600,”m”)&” m/o”,(E600-F600)>730,DATEDIF(F600,E600,”y”)&” y/o”)
\\\\\\\\\\\\\
=IFS(DATEDIF(F600,E600,”d”)<=6,DATEDIF(F600,E600,”d”)&” d/o”,AND(DATEDIF(F600,E600,”d”)<=59,DATEDIF(F600,E600,”d”)>=7),DATEDIF(F600,E600,”d”)/7&” w/o”,AND(DATEDIF(F600,E600,”d”)>=60,DATEDIF(F600,E600,”m”)<=24),DATEDIF(F600,E600,”m”)&” m/o”,DATEDIF(F600,E600,”m”)>25,DATEDIF(F600,E600,”y”)&” y/o”)
\\\\\\\\\\\\\
=DATEDIF(F600,E600,IFS((E600-F600)<7,”d”&” d/o”,AND((E600-F600)>7,(E600-F600)<60),”d”/7&” w/o”,AND((E600-F600)>60,(E600-F600)<730),”m”&” m/o”,(E600-F600)>730,”y”&” y/o”))
\\\\\\\\\\\\\\
Any help on this would be greatly appreciated!
=LOOKUP(E600-F600,{0,8,56,730},INT(DATEDIF(F600,E600,{"d","d","m","y"})/{1,7,1,1})&" "&{"d","w","m","y"}&"/o")
though your listed criteria state only "if younger than", "if older than", so it's not clear in which category someone who, for example, is precisely 7 days old should lie.
#Jos Woolley's example worked great. Another solution is posted below if anyone is troubleshooting their own formula in the future.
=IF(E600 < F600 + 7, DATEDIF(F600, E600, "d") & " d/o", IF(AND(E600 >= F600 + 7, E600 <= EDATE(F600, 2)), ROUNDDOWN(DATEDIF(F600, E600, "d") / 7, 0) & " w/o", IF(AND(E600 >= EDATE(F600, 2), E600 <= EDATE(F600, 24)), DATEDIF(F600, E600, "m") & " m/o", DATEDIF(F600, E600, "y") & " y/o")))
The excel user will export the data from an online website to excel (12 months data), so the data will be all the time different.
I need the past 6 months and 12 months average (However, the calculation need to use the months I have in the data, and sometimes there will be less then 6 or 12 months), but I still need to get the average and frequency for it , however, I am not sure how to get it.
I am trying to write a code, but it is not complete and is not working as well, I don't get an error; it just doesn't work.
I am open for Excel formulas as well, the problem may be the last row and that it need to use the data I have to calculate and not 6 and 12 months full.
PS: I post a similar question on https://www.ozgrid.com/forum/index.php?thread/1227312-dynamic-way-to-calculate-the-last-6-months-average/
Will This formulas work for you?
Average for last 6 months:
=AVERAGEIF(A:A;">="&EDATE(MAX(A:A);-6);B:B)
Frequency for last 6 months:
=IF(MONTH(MAX(A:A)-MIN(A:A))>=6;COUNTIF(A:A;">="&EDATE(MAX(A:A);-6))/6;COUNTIF(A:A;">="&MIN(A:A))/MONTH(MAX(A:A)-MIN(A:A)))
Average for last 12 months:
=AVERAGEIF(A:A;">="&EDATE(MAX(A:A);-12);B:B)
Frequency for last 12 months:
=IF(MONTH(MAX(A:A)-MIN(A:A))>=12;COUNTIF(A:A;">="&EDATE(MAX(A:A);-12))/12;COUNTIF(A:A;">="&MIN(A:A))/MONTH(MAX(A:A)-MIN(A:A)))
I'm working on an Assignment where 2 different Date Ranges are available. I'm trying to add their differences and formatting them in XX Years, XX Months, XX Days (where XX is the Sum Number).
Now for a single range, I've searched on internet and Found DATEDIF Function useful like in Below image:
Formula
=DATEDIF(Start_Date_1,End_Date_1,"y")&" Years, "&DATEDIF(Start_Date_1,End_Date_1,"ym")&" Months, "&DATEDIF(Start_Date_1,End_Date_1,"md")&" Days"
It works Fine for 1 Date Range. But I've 2 different Ranges and 2 Different Differences. So I've tried to Sum the Each Parameter (Year, Month & Days) in the above formula Like Below:
Formula:
=DATEDIF(Start_Date_1,End_Date_1,"y")+DATEDIF(Start_Date_2,End_Date_2,"y")&" Years, "&DATEDIF(Start_Date_1,End_Date_1,"ym")+DATEDIF(Start_Date_2,End_Date_2,"ym")&" Months, "&DATEDIF(Start_Date_1,End_Date_1,"md")+DATEDIF(Start_Date_2,End_Date_2,"md")&" Days"
Now the Formula works fine until the Months/Days Range exceed 12/31 Respectively. As Seen in the picture, The months range has summed up to 13 while Days to 32. Now I'm looking for any solution or even Different approach to do the same formatting. Any Solution or Suggestion will be highly appreciated.
Thanks in Advance :).
If you define a month as 30 days you could just nestle IF's to compensate:
=IF(DATEDIF(Start_Date_1,End_Date_1,"md")+DATEDIF(Start_Date_2,End_Date_2,"md")>30,IF((DATEDIF(Start_Date_1,End_Date_1,"ym")+DATEDIF(Start_Date_2,End_Date_2,"ym")+1)>11,(DATEDIF(Start_Date_1,End_Date_1,"y")+DATEDIF(Start_Date_2,End_Date_2,"y")+1)&" Years, "&(DATEDIF(Start_Date_1,End_Date_1,"ym")+DATEDIF(Start_Date_2,End_Date_2,"ym")-11)&" Months, "&(DATEDIF(Start_Date_1,End_Date_1,"md")+DATEDIF(Start_Date_2,End_Date_2,"md")-30)&" Days",(DATEDIF(Start_Date_1,End_Date_1,"y")+DATEDIF(Start_Date_2,End_Date_2,"y"))&" Years, "&(DATEDIF(Start_Date_1,End_Date_1,"ym")+DATEDIF(Start_Date_2,End_Date_2,"ym")+1)&" Months, "&(DATEDIF(Start_Date_1,End_Date_1,"md")+DATEDIF(Start_Date_2,End_Date_2,"md")-30)&" Days"),DATEDIF(Start_Date_1,End_Date_1,"y")+DATEDIF(Start_Date_2,End_Date_2,"y")&" Years, "&DATEDIF(Start_Date_1,End_Date_1,"ym")+DATEDIF(Start_Date_2,End_Date_2,"ym")&" Months, "&DATEDIF(Start_Date_1,End_Date_1,"md")+DATEDIF(Start_Date_2,End_Date_2,"md")&" Days")
So IF days are over Thirty we check if months+1 are over 11, if both yes we minus 30 from days, 11 from months (11 to compensate a year plus the month from days) and add 1 to years, if months+1 aren't over 11 we simply add one to months and minus 30 from days, if neither are over the limits then we display the unadulterated formula.
(using your images as an example:
=IF(DATEDIF(A3,B3,"md")+DATEDIF(E3,F3,"md")>30,IF((DATEDIF(A3,B3,"ym")+DATEDIF(E3,F3,"ym")+1)>11,(DATEDIF(A3,B3,"y")+DATEDIF(E3,F3,"y")+1)&" Years, "&(DATEDIF(A3,B3,"ym")+DATEDIF(E3,F3,"ym")-11)&" Months, "&(DATEDIF(A3,B3,"md")+DATEDIF(E3,F3,"md")-30)&" Days",(DATEDIF(A3,B3,"y")+DATEDIF(E3,F3,"y"))&" Years, "&(DATEDIF(A3,B3,"ym")+DATEDIF(E3,F3,"ym")+1)&" Months, "&(DATEDIF(A3,B3,"md")+DATEDIF(E3,F3,"md")-30)&" Days"),DATEDIF(A3,B3,"y")+DATEDIF(E3,F3,"y")&" Years, "&DATEDIF(A3,B3,"ym")+DATEDIF(E3,F3,"ym")&" Months, "&DATEDIF(A3,B3,"md")+DATEDIF(E3,F3,"md")&" Days")
Will work for you)
Is there an easy way to tally a column formatted as follows: "5/24/2013 5:48:00 PM"
What I want to do is have it tally by day of week and an hour time block, the end result I'm looking for would look like the following:
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
1:00-2:00AM 10 2 8 7 3 12 15
2:00-3:00AM 5 4 7 7 9 11 18
et cetera. This is an extremely large data set so avoiding doing this by hand would be amazing. I apologize if this is a terrible question, I tried searching though other people's questions to no avail.
Not knowing the details, I would try to use a PivotTable.
There is the ability to group by dates; see this page for details (including a fancy animation).
Some additional searching should turn up a lot of resources on PivotTables; they are very powerful.
I'd assign a number to the rows/columns and then use sumif().
I would create add two columns: one with =Hour(A2), other with =WeekDay(A2) (example for row 2, assuming dates are on column A).
Then, use PivotTable on all data.
Regard formats: WeekDay must be formated as ddd or dddd and Hour as numeric.
I'm a teaching assistant for a school working with kids with special needs and I've been asked to produce a spreadsheet that can keep track of their reading ages and spelling ages as they progress through the school. They have two tests per year, about every 6 months, so I'm using a column for the test result and the adjacent column for their improvement over their last test.
However, in order for the improvement to work properly, I need to get the cells from H2 to (for example) V20 to work in base 12 so i can perform functions on it. I've found a way of converting the output of a call to display in base 12, but that's all I can use it for - Base 12.
An example of how I've got it now would be as follows:
Reading age after year 7 test 1 - 7
Reading age after year 7 test 2 - 7.2 (not 7.2 years, 7 years and 2months.)
Reading age after year 8 test 1 - 7.8 (again, 7 years and 8 months)
Reading age after year 8 test 2 - 7.11 (so rather than being 7 units, 1 tenth and 1 hundredth, it would be 7 years and 11 months)
The formula to work out the improvement on per test is as follows:
=IF(OR(ISBLANK(H2),ISBLANK(I2))," ",(I2-H2))
My issue is getting the cells within this area to work (or think?) as if they are working with months, rather than decimals.
I'd suggest that you need to use 7.01 for 7 years 1 month so that you can distinguish between that and 7.10 (7 years 10 months). If you use that approach then you can use DOLLARDE and DOLLARFR functions to handle base 12, e.g.
=IF(COUNT(H2,I2)=2,DOLLARFR(DOLLARDE(I2,12)-DOLLARDE(H2,12),12),"")