• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Date/Reminder with Conditional Formatting

kmakifl

Member
My spreadsheet involves calculating when evaluations are due; from hire date or promotion = Start/Promotion, +45 days, +90 days, +180, annual. Some of the evaluations

way overdue. In some instances, I may only have the hire date, which could be 9/2/08, I don't want the result to show "False" or -4082686 days late. Thanks for your help.


I am using this conditional formating


=IF(E4>(B4-5),TEXT(E4-NOW(),"#")&"days left")


Hire Date 45 days Due 90 days Due 6mon Feedback Due

10/3/2011 11/14/2011 35days left 1/3/2012 85days left 3/31/2012 173days

1/18/2011 FALSE 4/18/2011 FALSE

8/1/2000 FALSE -40826days
 
Hi kmakifl

Don't know if this is what you're looking for But, I've posted a file here:

http://dl.dropbox.com/u/16092591/Datedif.xlsx

Hope this helps.

Shalom
 
If your existing formula works except for the negative numbers and false values, here's the problem:


IF() should have three parameters

Code:
IF(condition,truepart,falsepart)

If the third parameter is missing, then when your condition is false, it will display "False".  If you want it to be blank, just put "" there.


To eliminate negatives you could change the condition in your IF from [code]E4>(B4-5) to [code]AND(E4>(B4-5),E4-NOW()>0).  You could also change the format string from [code]"#" to [code]"# ""days left"";;;" and get rid if the &"days left"
part of your formula, to achieve the same displayed text (blank if zero or negative).


This formula is entered as conditional formatting for what cell? E4? Or do you mean it is the formula entered into a cell directly? It sounds like the latter.. a conditional formatting expression should evaluate to true or false, with formula in the cell just calculating the desired value.


If you put:

=IF(E4>(B4-5),E4-NOW(),0)[/code]


in your cell, and just format the cell with the following custom format:


# "days left";;;[/code]


Then you should get the displayed text you want and still be able to do numerical calculations based on that cell. With this version, numerical calculations will see the negative numbers even though they won't be displayed.


If you don't want calculations to see the negatives or zeroes either, use this formula:

=IF(AND(E4>(B4-5),E4-NOW()>0),E4-NOW(),"")[/code]


and this format (no need to hide zeroes/negatives -- they aren't there -- you may want to see them when it will indicate an error in your formula):

# "days left"[/code]


Asa
 
Auto and Asa, thank you for replies, both options look like they will work. I will try them.

PS sorry for my late reply, I just figured out how to find the replies :)
 
Auto,


IF(AND(DATEDIF($C$3,TODAY(),"d")>F6,DATEDIF($C$3,TODAY(),"d")>=G6),"OVERDUE"&" by "&DATEDIF($C$3+F6,TODAY(),"d")&" days.","")


I like the format and formula; I would need to edit the formula to copy for 26 employees with different start date. The $c$3 would not be same for all employees.
 
If you provide what data is causing the formula to give a VALUE error, I can tell you what the problem is.


I simply fixed the main error in your formula and moved the formatting out of the formula into the cell format, but I'm not clear on what data is in what cells.


Actually, if you post a link to a sample spreadsheet it will be very clear :)


Code:
DATEDIF(date1,date2,"d") is equivalent to [code]date2-date1
, by the way. TODAY()[/code] is the current date without the time of day element (equivalent to 12:00 AM midnight today for calculations).


What's the 5-day calculation for in your formula?


My method of finding replies on here is to add all threads I reply to as "favorites" and subscribe to the RSS feed of my favorites.


Asa
 
asa,

You're right about the datedif equivalence don't know what I was thinking. Still, it seemed to work.

kmakifl,

Hope you can adapt it to your needs. asa will keep you right.
 
Any file sharing site is fine. Some suggestions are here: http://chandoo.org/forums/topic/posting-a-sample-workbook


I also like box.net.


Asa
 
Hey auto,

I have nothing against using datedif...


Hi kmakifl,


Column B is Hire Date,

C, Annual,

D, Promotion Date,

E, 45 (Day Eval Due Date)

F, Status (days until due, 45 day eval)

G, 90 (Day Eval Due Date)

H, Status (for 90 days)

I, 180

J, Status (180)

K, 365

L, Status (365)


Hopefully got the meaning of those columns right. My words in parenthesis.


You have some kind of logic in your formula so that your evals aren't due exactly at n-days past hire date, but -- perhaps your are aiming for -- the same day of the week as the hire date, and will fall up to 5 days early to fall on that same day. i.e. cell E4 (45 day eval, employee a) has
Code:
=B4+40+WEEKDAY(B4,1)


If I got your aim there right, the formula is flawed.  Consider employee B.  Hired 1/18/2011, a Tuesday.  The calculated 45-day eval date is 43 days later on 3/2/11. But 3/2/11 is a Wednesday.  The problem might be worse for employees x and ac, had this formula been used.  They would be scheduled for 2/20/2010, a Saturday (41 days after hiring.  The actual 45-day date would be the following Wednesday, 2/24/2010).  For employee h you use the formula [code]=B11+E3 which simply adds 45 days to the hire date, snagged from the column heading in E3, which is fine.  That's a Saturday as it turns out too, but it's just a due date.  A special calculation to end up on a weekend is odd to me though.  The question is do you want perhaps the business day before the date as the eval date, or the business day after... or just list the date and figure it out when your weeks are planned.


For the exact day, you could take the lead from the formula for employee h, but use an absolute cell reference ($) so you can copy the formula to other rows and have it still refer to the column heading, plus check for a missing hire date and leave the eval date blank too in that case like this, for employee a:

[code]=IF(ISBLANK($B4),"",$B4+E$3)

(lock onto the hire date column for copying to 90/180/etc. hire date column with [code]$B, lock onto the number of days from the heading with the $3
.)


For the business day before (M-F, even holidays):

=IF(ISBLANK($B4),"",IF(WORKDAY($B4+E$3,0)=$B4+E$3,$B4+E$3,WORKDAY($B4+E$3,-1)))[/code]

(if the eval date would be a work day, use it, otherwise use the workday before.)


For the business day after (M-F, even holidays):

=IF(ISBLANK($B4),"",IF(WORKDAY($B4+E$3,0)=$B4+E$3,$B4+E$3,WORKDAY($B4+E$3,1)))[/code]

(if the eval date would be a work day, use it, otherwise use the workday after.)


Check the help for the WORKDAY and WORKDAY.INTL functions if you want to specify holidays or different work days. This function should simplify the calculation compared to trying to do calculations off of WEEKDAY.


These formulas could be copied to any cell in the 45, 90, 180, or 365 column and will calculate the appropriate date.


------

As to your calculations for the Status columns, which is what you were actually asking about, I recommend basing off of the 45-90-180-365 due dates as listed in those respective columns.


Your formula, as it looks in cell F4 (Status for 45-Day, employee a):

=IF(AND(E4>(B4-5),E4-NOW()>0),E4-NOW(),"")[/code]


Could be read:

If the 45-Day_Evaluation_Date is subsequent to 5 days before Hiring and the timespan between the 45-Day_Evaluation_Date and NOW is more that 0 days (i.e. the 45-day_eval_date is in the future), then indicate the timespan for status, otherwise, indicate nothing.


Won't the 45-Day eval ALWAYS be subsequent to 5 days before hiring? Heck, I doubt it's even ever before hiring at all. This check seems to relate to the unusual logic for calculating the eval date discussed above, but I don't think any of that logic is required here, and since evals are always after hires, it serves no purpose as written.


If we eliminate that, we have:

Code:
=IF(E4-NOW()>0,E4-NOW(),"")


Which is OK, but it's good practice to use TODAY() instead of NOW() when you're not interested in the time of day.  You could get unexpected results in some calculations, otherwise.


So,

[code]=IF(E4-TODAY()>0,E4-TODAY(),"")


OK, but for employee d, this results in a #VALUE error.

If you select cell F7 (Status for employee d), where the error is, you'll see an exclamation mark button appear next to the cell. Click on it, then click on "Show calculation steps" and you'll see it underline the first part of the formula it evaluated, [code]E7-TODAY() in [code]E7-TODAY()>0, which evaluates to [code]""-40830
. Since the 45-day eval date is missing for that employee, it is trying to subtract today's date from an empty text, which is impossible.


There are several solutions. The simplest is to use the N(x) function which will give you x if x is a number, otherwise it will give you 0. N(E7) will do the same for E7, the eval date. 0-TODAY will of course be a negative number, but anything <= 0 is already discarded by your formula, so this is harmless.


This would give us, back in row 4, employee a:

=IF(N(E4)-TODAY()>0,E4-TODAY(),"")[/code]


Copy this formula to all cells in all Status columns, and you will have either a number or a blank, but no errors.


Apply the custom number format to all the status cells that I mentioned in my first post:

# "days left"[/code]


And it will include the words "days left" after the displayed number.


If you decide to add a column for when the 45/90/180/365 day evals were actually done, or at lease IF they were actually done, you could do a couple things. You could change this formula to a version that allows negatives (when an eval date is listed of course, and only if no eval has been completed), and then you could change your custom format to something like:

# "days left";[Red]# "days overdue"[/code]


Which will put negatives in red with the word "overdue" instead of a minus sign.


I see you have color key with a background red for past due and background pink for due within 2 weeks. To accomplish that, you'd have to use a conditional formatting rule.


Change the cell custom number format to:

# "days left";# "days overdue"[/code]

(color will be handled by conditional formatting)


Then you'd create two conditional formatting rules for the status cells. Highlight the status cell>conditional formatting>highlight cell rules>Between...> and then specify a low range of 0 and high of 14, and select a pink fill. Similarly with the same range selected, >highlight cell rules>Less Than>0>red fill.


Hope this was informative.


Asa
 
Back
Top