For the below, I'm looking for an excel if function that'll let me know how old each of the items are (less than 3 days, Less than 7 days, Less than 14 days, Greater than 14 days)
Create a table outlining your cut offs and then use a VLOOKUP.
In C2, add =VLOOKUP(TODAY()-B2,$F$2:$G$6,2,1) and drag down as needed
The benefit with going this route is that you don't have to update complicated IF statements if you ever needed to change the buckets. Say for instance, in the future you want to add 5 more categories. Here that would just mean updating 5 rows on a single table rather nesting 5 more criteria to an IF statement.
A simple verbose formula...
=IF(TODAY()-B3<=7,"Less than equal to seven",IF(TODAY()-B3<=14,"Less than or
equal to fourteen days",IF(TODAY()-B3<=21,"Less than or equal to twenty one
days","greater than 21 days")))
Need to format the cell this is in as a number with no decimal places.
This formula should do the trick:
=IF((TODAY()-B1)<3,"Less than 3 days",
IF((TODAY()-B1)<7,"Less than 7 days",
IF((TODAY()-B1)<14,"Less than 14 days",
IF((TODAY()-B1)>=14,"Greater than 14 days",""))))
Please notice that I used >=14.
Reason is otherwise you wont get the rows where the difference is exactly 14.
But feel free to change it to >14 if that's fit your need better :)
you can use tha TODAY() function to get the current date and than compare it with the dates you have:
so the table that you will have is like:
table, th, td {
border: 1px solid black;
}
<table style="width:100%">
<tr>
<th>5/12/2020</th>
<th>=TODAY()-B1</th>
<th>=if(C1<3, "less than 3 days", if(C1<7, "less than 7 days", if(C1<14, "less than 14 days", "more than 14 days")))
</th>
</tr>
<tr>
<th>5/10/2020</th>
<th>=TODAY()-B2</th>
<th>=if(C1<3, "less than 3 days", if(C1<7, "less than 7 days", if(C1<14, "less than 14 days", "more than 14 days")))
</th>
</tr>
</table>
Related
I am attempting to determine the number of months and days between two dates to determine an group of individuals length of service, so that I can ascertain if they are within 2 ranges 0-6 mths and 6-23mths, I have the following but I'm missing something, as it can't seem to handle 10 months or over, its returning 0-6 mths for those. I will also need to add a third range (0-6, 6-12 & 12-23) for a future project but am having difficulties with this one also?
=IF(DATEDIF(F155,G155,"ym")&" months " &DATEDIF(F155,G155,"md")&" days">="6 months 0 days", "6 - 23 Months","0 - 6 Months")
The problem is that you are comparing 2 strings that do not have the same format:
For example for dates 1/1/2019 with 11/1/2019 you are comparing "10 months 0 days" vs "6 months 0 days" (a 2 digits number vs a 1 digit number in the begining strings). You have to make them the same format to be able to compare:
=IF(DATEDIF(F155,G155,"ym")&" months " &RIGHT("0"&DATEDIF(F155,G155,"md"),2)&" days">="06 months 00 days", "6 - 23 Months","0 - 6 Months")
This way you would be comparing "10 months 00 days" vs "06 months 00 days" and since now they have the same format it will work.
It might be simpler to use VLOOKUP.
And, if you expect to get a range of 12-23 months, why are you using the "ym" argument for DATEDIF? That can never return a value more than 12.
I suggest something like:
=VLOOKUP(DATEDIF(F155,G155,"m"),{0,"0 to 6 months";6,"6 to 12 months";12,"12 to 23 months";24,"undefined"},2)
Also, suggest you read about the different arguments for DATEDIF; and you should probably read HELP for VLOOKUP also.
If you need to extend the table more, consider putting it into an Excel table instead of an array constant.
I have an Excel formula where I check if the value is above or below a certain threshold. My list contains both numbers and text.
Example:
Column A
10
20
30
No value
40
50
I want to group all the values >=30 "Above 30",the ones between 30 and 10 "Between 30 and 10" and "No value" and 10 in "Below 10".
This is the formula that I use:
=if(A1>=30,"Above 30", IF(A1<10,"Below 10","Between 30 and 10))
Everything is okay with the numbers but "No value" is marked as "Above 30".
What could be the reason for that?
Thank you!
I think you want (a) another double quote and (b) to combine (OR) the case where under 10 or Text:
=IF(OR(ISTEXT(A1),A1<10),"Below 10",IF(A1>=30,"Above 30","Between 30 and 10"))
The OR needs to be first to take advantage of IF's short circuiting.
Excel sorts (ascending) any Text after any Number.
I want to be able to check if data in one cell in column a = x and then if so count the data in adjacent cell in column b.
To explain in more detail, I am creating a statistics chart where commissioners need to be able to be able to compare data for region 1 to region 2 and region 3.
So column A will contain region keys such as 1, 1, 1, 2, 3, 3 then in column B will be ages. So if column A contains a 1 collect data in cell adjacent to the cell it is counting.
I hope this makes sense.
So I want the formula to only count the cells that adjacent cells contain district 1 for example
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
<table style="width:100%">
<tr>
<td>A</td>
<td>B</td>
</tr>
<tr>
<td>District 1</td>
<td>12</td>
</tr>
<tr>
<td>District 2</td>
<td>12</td>
</tr>
<tr>
<td>District 1</td>
<td>12</td>
</tr>
<tr>
<td>District 2</td>
<td>12</td>
</tr>
</table>
You just need to use COUNTIFS() to add extra criteria to when to count something.
Using the following data:
Region Age
2 12
2 16
2 41
1 62
3 26
3 50
2 12
1 65
3 64
Where Region = B1 we can use =COUNTIFS(A2:A10,2,B2:B10,12) to count the instances where Region = 2 and where Age = 12. This returns 2.
Obviously we can expand this out to all manner of criteria or keep adding extra criteria. Having data that looks like:
Region Age Ethnicity
2 12 Black
2 16 Caucasian
2 41 Asian
1 62 Black
3 26 Caucasian
3 50 Asian
2 12 Caucasian
1 65 Caucasian
3 64 Asian
We can now count Asian people equal to or over the age of 50 in region 3 with =COUNTIFS(A2:A10,3,B2:B10,">=50",C2:C10,"Asian")
And if you want to bucket people using upper and lower bounds it's simply a case of creating the bound in separate ranges and criteria pairs. For instance to find all people in region 2 aged between 10 and 20 (not inclusive on the upper bound) we would use =COUNTIFS(A2:A10,2,B2:B10,">=10",B2:B10,"<20")
I need to calculate the working hours elapsed between two dates and times, for example:
Holiday taken between 01/09/2014 and 05/09/2014
5 working days # 8 hours per day.
I need the result to show me how many working hours that would be. For example:
ANNUAL ENTITLEMENT: 89.9 Hours
DATE FROM DATE TO RETURN TO WORK HOURS REQUIRED HOURS REMAINING DATE
01/09/2014 05/09/2014 06/09/2014 40 49.90
I have no idea if this is even possible!
I am assuming these are given cells. if you type in the date to a cell you can click on a new cell and put uptop by the fx this
for example. In C1 you can type this into the fx. Make sure you put the equal sign.
=B1-A1
This is what is the dates in the cells
A1 = 1/9/2014
B1 = 5/9/2014
This will give you 120 which is the total days inbetween.
You will want to get the number of weeks so you can divide by 7.
You will multiply weeks by number of days worked which is 5
Then you want the weeks times 8 hours you can do this in C1
=(B1 - A1)/7 * 5 * 8
which gives you 685.7143
you need to also take into account weekends which a simple subtraction will not do. Firstly find the total number of days:
TOTAL_NUMBER_DAYS = B1-A1 + 1
then calculate how many weekends:
TOTAL_WEEKENDS = WEEKNUM(B1) - WEEKNUM(A1)
finally take the total days and subtract weekends:
NET_TOTAL_DAYS = TOTAL_NUMBER_DAYS - (TOTAL_WEEKENDS * 2)
TOTAL_HOURS = NET_TOTAL_DAYS * 8
I solved this recently and had a working solution initially in Excel 2013. Slightly adapted to work in 2007 (lack of 'Days()' function). We use it for reporting on support tickets (length of time between opening and closing a ticket).
Inputs are "Workday start", "Workday end" from which "Hours worked" and "Hours not worked" are calulated.
Hours worked =HOUR(WorkEnd-WorkStart)+(MINUTE(WorkEnd)+MINUTE(WorkStart))/60
Hours not worked = 24 - Hours worked
Further inputs are a table ("Data") with first two columns "Open" and "Close", which are dateserial cells.
Next column is standard numeric value "Gross hours" =(Data[[#This Row],[Close]]-Data[[#This Row],[Open]])*24
Next column is standard numeric value "Net workdays" =NETWORKDAYS(Data[[#This Row],[Open]],Data[[#This Row],[Close]])
Next column is standard numeric value "Net days" =MAX(1,DAY(Data[[#This Row],[Close]])-DAY(Data[[#This Row],[Open]]))
Next column is standard numeric value "Gross workhours" =IF(Data[[#This Row],[Gross hours]]>0,Data[[#This Row],[Gross hours]]-24*(Data[[#This Row],[Net days]]-Data[[#This Row],[Net workdays]]),0)
Last column is standard numeric value "Total work hours" =IF(Data[[#This Row],[Gross workhours]]<24,Data[[#This Row],[Gross workhours]],Data[[#This Row],[Gross workhours]]-(HoursNotWorked*Data[[#This Row],[Net workdays]]+HoursWorked))
This solution makes it trivial to adjust start and end work times, as well as accounting for any holidays (via a small change to the NETWORKDAYS() function to utilise the optional parameter).
Formula is to find the difference of multiples to be used in excel for an ordering form. For example, orders of items must be placed in multiples of 6, for every 6 ordered you get one free. So for 6 calculated result needs to display "1 item free". For 12 calculated result needs to show "2 items free". For 11 would need to display "Order 1 more, or 5 less".
How do I define this formula/calculation in an excel spreadsheet?
You want modular math:
e.g. 14 items purchased, buy in groups of 5:
14 mod 5 = 4
buy 1 more (5 - 4) or 4 less.