SOLVED

IF Statements on variable dates

%3CLINGO-SUB%20id%3D%22lingo-sub-2278763%22%20slang%3D%22en-US%22%3EIF%20Statements%20on%20variable%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2278763%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Everyone%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EThe%20Question%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3EI%20am%20looking%20for%20help%20in%20constructing%20an%20IF%20statement%20or%20another%20formula%20to%20auto-generate%20Expiry%20dates%20based%20on%20variable%20rules.%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EA%20Little%20'O%20Context%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3EThis%20information%20is%20used%20as%20part%20of%20a%20small%20database%20that%20permits%20marine%20traffic%20through%20a%20controlled%20area.%20The%20data%20is%20mostly%20input%20by%20myself%2C%20however%2C%20there%20are%20some%20other%20users%20in%20my%20organisation%20and%20a%20number%20of%20people%20who%20read%20the%20output%20information.%3C%2FP%3E%3CP%3EThe%20data%20needs%20to%20be%20precise%20as%20it%20is%20used%20by%20decisions%20makers%20in%20my%20organisation%20and%20is%20sometimes%20made%20available%20to%20outside%20parties.%20Further%2C%20this%20will%20reduce%20the%20human%20element%20in%20the%20calculation%2C%20therefore%2C%20reducing%20the%20potential%20for%20error%20and%20promotes%20better%20reporting%20down%20the%20line.%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EThe%20Data%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CUL%3E%3CLI%3EColumn%20B%20-%20The%20date%20a%20vessel%20was%20inspected.%3C%2FLI%3E%3CLI%3EColumn%20C%20-%20The%20date%20of%20painting%20(for%20the%20antifouling%20paint%20of%20vessel%20hulls%2C%20it%20has%20a%20time%20frame%20of%20effectiveness).%20This%20date%20is%20colour%20coded%20using%20Conditional%20Formatting%20being%20a%20visual%20representation%20of%20Column%20D.%3C%2FLI%3E%3CLI%3EColumn%20D%20-%20This%20is%20a%20column%20to%20identify%20the%20approx.%20age%20of%20the%20antifoul.%20It%20is%20identified%20through%20an%20IF%20statement.%3C%2FLI%3E%3CLI%3EColumn%20E%20-%20The%20inspection%20is%20valid%20for%20different%20times%20based%20on%20the%20age%20of%20the%20paint%2C%20brand%2C%20use%20and%20coat%20thickness.%20The%20inspection%20becomes%20invalid%20if%20the%20paint%20reaches%20its%20term%20of%20effectiveness.%20This%20data%20is%20expressed%20in%20the%20number%20of%20months%20the%20paint%20is%20effective.%3C%2FLI%3E%3CLI%3EColumn%20F%20-%20Lastly%2C%20this%20date%20represents%20the%20end%20of%20effectiveness%20for%20the%20paint.%20This%20date%20is%20calc'd%20using%20an%20EDATE%20formula.%3C%2FLI%3E%3C%2FUL%3E%3CP%3EThe%20key%20time%20frames%20of%20the%20age%20of%20paint%20are%3C%2FP%3E%3CUL%3E%3CLI%3E0-3%20months%2C%20inspection%20lasts%20for%206%20months%20(not%20that%20much%20different%20from%206-12%20months%20but%20has%20key%20policies%20around%20it%20that%20are%20different%20to%20the%20next%20category%2C%26nbsp%3B%3C%2FLI%3E%3CLI%3E6-12%20months%2C%20inspection%20lasts%20for%206%20months%20but%20not%20longer%20than%2012%20months%20from%20the%20date%20in%20Column%20C%20(original%20painting).%3C%2FLI%3E%3CLI%3EBeyond%2012%20Months%2C%20inspection%20lasts%203%20months%20and%20is%20invalid%20after%20the%20date%20in%20Column%20F%20is%20reached.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EGuys%2C%20I%20tried%20and%20I%20Googled%3B%3C%2FSTRONG%3E%3C%2FP%3E%3CP%3EI%20started%20this%20task%20a%20few%20days%20ago.%20I%20have%20started%2C%20come%20close%20but%20not%20quite%20right%20and%20sometimes%20completely%20failed.%20I%20have%20gone%20to%20google%20and%20found%20solutions%20that%20look%20close%20but%20do%20not%20work.%20I%20have%20focused%20on%20IF%20statements%20and%20expressions%2C%20however%2C%20have%20tried%20some%20other%20formulae%20that%20may%20work%20with%20no%20luck.%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EExtra%20Info%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3EI%20have%20attached%20an%20example%20spreadsheet%20as%20the%20other%20information%20on%20the%20original%20is%20commercially%20sensitive.%20In%20columns%20J%20to%20L%2C%20I%20have%20included%20what%20the%20dates%20should%20be%20based%20on%20the%20rules%20as%20set%20above.%3C%2FP%3E%3CP%3E%3CU%3E%3CSTRONG%3EMany%20thanks%20for%20your%20help%3B%3C%2FSTRONG%3E%3C%2FU%3E%3C%2FP%3E%3CP%3EI%20would%20appreciate%20any%20help.%20I%20am%20continuing%20to%20work%20on%20this%20and%20if%20I%20find%20the%20solution%20I%20will%20post%20for%20the%20completion%20and%20future%20'Googlers'.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2278763%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2279532%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statements%20on%20variable%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279532%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1031069%22%20target%3D%22_blank%22%3E%40TheLimbix%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EDoes%20this%20do%20it%3F%3C%2FP%3E%3CP%3EI%20have%20converted%20to%20a%20table%20to%20keep%20the%20data%20and%20formulas%20in%20sync.%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-excel%22%3E%3CCODE%3E%3D%20MIN(%0A%20%20%20EDATE(%5B%40%5BInspection%20Date%5D%5D%2C%20IF(today-%5B%40%5BAntiFoul%20Application%20Date%5D%5D%20%26lt%3B%20182%2C%206%2C%203))%2C%0A%20%20%20%5B%40%5BAntifoul%20Expiry%5D%5D%20)%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2279500%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statements%20on%20variable%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279500%22%20slang%3D%22en-US%22%3EYou%20basically%20repeated%20your%20first%20post.%20I%20was%20looking%20for%20step%20by%20step%20through%20the%20first%20three%20examples%2C%20how%20you%20got%20the%20answer%20in%20col%20J%2C%20which%20means%2C%20I%20guess%2C%20how%20you%20got%20the%20info%20in%20column%20L.%3CBR%20%2F%3E%3CBR%20%2F%3EI'm%20asking%20you%20to%20be%20VERY%20basic%2C%20explain%20step%20by%20step%2C%20what%20leads%20to%20the%20right%20answer%2C%20for%20those%20examples%20you%20give%20in%20rows%202%2C%203%20and%204.%20What%20you've%20given%20is%20the%20higher%20level%20rules%2C%20but%20you've%20not%20%22applied%20them%22%20visibly%2C%20by%20which%20I%20mean%2C%20so%20that%20all%20I%20(or%20any%20other%20person%20here)%20needs%20to%20do%20is%20translate%20your%20words%20for%20rows%202%2C%203%20and%204.%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2279469%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statements%20on%20variable%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279469%22%20slang%3D%22en-US%22%3E%3CP%3EThanks%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F425987%22%20target%3D%22_blank%22%3E%40mathetes%3C%2FA%3E%26nbsp%3Bthat%20is%20a%20good%20point%2C%20it%20is%20clear%20in%20my%20mind.%20I'll%20do%20my%20best%20to%20describe%20this%20in%20words.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSTRONG%3EColumn%20A%3C%2FSTRONG%3E%20is%20a%20starting%20point%20so%20to%20speak.%20I%20am%20given%20a%20form%20with%20a%20date%20on%20it%2C%20that%20is%20when%20the%20date%20of%26nbsp%3B%20inspection%20and%20when%20the%20valid%20period%20begins.%3CBR%20%2F%3EOn%20that%20same%20form%20is%20a%20date%20which%20is%20put%20into%20%3CSTRONG%3EColumn%20C%3C%2FSTRONG%3E.%20This%20is%20the%20date%20that%20sets%20the%20conditions%20for%20how%20long%20the%20inspection%20will%20be%20valid%20for.%3CBR%20%2F%3E%3CSTRONG%3EColumn%20D%3C%2FSTRONG%3E%20is%20the%20current%20age%20of%20the%20antifoul%20based%20on%20the%20date%20difference%20between%20TODAY()%20and%20Column%20C.%20This%20is%20the%20main%20parameter%20that%20sets%20the%20conditions%20for%20the%20inspection%20expiry.%20If%20the%20Date%20Dif%20between%20TODAY%20and%20Column%20C%20is%3B%3C%2FP%3E%3CUL%3E%3CLI%3EWithin%203%20Months%20the%20Inspection%20is%20valid%20for%206%20months%2C%3C%2FLI%3E%3CLI%3EWithin%206%20Months%20the%20Inspection%20is%20valid%20for%206%20months%20or%20until%20the%20date%20in%20Column%20F%20(Calc'd%20from%20Col'%20C%20and%20Col'%20E.%20Info%20for%20Col'%20E%20is%20also%20collected%20from%20the%20inspection%20form)%20reaches%2012%20months%20old%2C%20which%20ever%20comes%20first.%3C%2FLI%3E%3CLI%3EBeyond%2012%20Months%20until%20the%20date%20in%20Column%20F%20is%20reached%20the%20inspection%20lasts%20for%203%20months.%3C%2FLI%3E%3C%2FUL%3E%3CP%3E%3CSTRONG%3EColumn%20F%3C%2FSTRONG%3E%20is%20calc'd%20using%20the%20date%20supplied%20for%20Col'%20C%20and%20Col'%20E.%20In%20some%20cases%20this%20will%20be%20what%20sets%20the%20upper%20limit%20of%20the%20inspection.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20info%20I%20supplied%20in%20Column%20L%2C%20with%20Col'%20J%20being%20the%20desired%20output%2C%20is%20the%20months%20the%20reason%20why%20the%20expiry%20date%20is%20what%20it%20is.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2279083%22%20slang%3D%22en-US%22%3ERe%3A%20IF%20Statements%20on%20variable%20dates%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2279083%22%20slang%3D%22en-US%22%3EYou've%20given%20a%20lot%20of%20helpful%20info%2C%20but%20I'm%20still%20not%20quite%20understanding%20the%20whole.%20Maybe%20some%20of%20the%20other%20Excel%20experts%20can%20decipher%20all%20of%20this%3B%20I'm%20going%20to%20need%20to%20ask%20a%20few%20more%20questions%20to%20make%20sure%20I'm%20tracking%20with%20you.%20It's%20what%20I'd%20do%20if%20we%20were%20sitting%20down%20face-to-face.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20gather%20that%20it's%20column%20G%20where%20you%20want%20this%20final%20formula.%20(Please%20confirm)%3CBR%20%2F%3EI%20get%20that%20column%20J%20is%20the%20desired%20answer%2C%20i.e.%2C%20what%20should%20appear%20as%20a%20result%20of%20whatever%20formula%20is%20created%20in%20G%3CBR%20%2F%3EWhat%20I%20don't%20get%20yet%20is%20how%20each%20rule%20applies%20in%20each%20row.%20I.e.%2C%20what%20in%20columns%20B%20through%20F%20tells%20me%20which%20condition%20is%20to%20be%20met.%3CBR%20%2F%3E%3CBR%20%2F%3EIt%20will%20help%20--%20this%20is%20all%20very%20clear%20in%20your%20mind%2C%20I%20know%20--%20it%20will%20help%20if%20you%20walk%20through%20maybe%20the%20first%20three%20rows%2C%20describing%20(in%20words)%20HOW%20data%20in%20columns%20B%20through%20F%20lead%20to%20the%20answer%20in%20column%20J....from%20those%20verbal%20descriptions%2C%20then%2C%20our%20challenge%20is%20to%20create%20a%20single%20conditional%20formula%20that%20consistently%20produces%20the%20desired%20result.%3C%2FLINGO-BODY%3E
New Contributor

Hi Everyone,

 

The Question;

I am looking for help in constructing an IF statement or another formula to auto-generate Expiry dates based on variable rules.

A Little 'O Context;

This information is used as part of a small database that permits marine traffic through a controlled area. The data is mostly input by myself, however, there are some other users in my organisation and a number of people who read the output information.

The data needs to be precise as it is used by decisions makers in my organisation and is sometimes made available to outside parties. Further, this will reduce the human element in the calculation, therefore, reducing the potential for error and promotes better reporting down the line.

The Data;

  • Column B - The date a vessel was inspected.
  • Column C - The date of painting (for the antifouling paint of vessel hulls, it has a time frame of effectiveness). This date is colour coded using Conditional Formatting being a visual representation of Column D.
  • Column D - This is a column to identify the approx. age of the antifoul. It is identified through an IF statement.
  • Column E - The inspection is valid for different times based on the age of the paint, brand, use and coat thickness. The inspection becomes invalid if the paint reaches its term of effectiveness. This data is expressed in the number of months the paint is effective.
  • Column F - Lastly, this date represents the end of effectiveness for the paint. This date is calc'd using an EDATE formula.

The key time frames of the age of paint are

  • 0-3 months, inspection lasts for 6 months (not that much different from 6-12 months but has key policies around it that are different to the next category, 
  • 6-12 months, inspection lasts for 6 months but not longer than 12 months from the date in Column C (original painting).
  • Beyond 12 Months, inspection lasts 3 months and is invalid after the date in Column F is reached.

Guys, I tried and I Googled;

I started this task a few days ago. I have started, come close but not quite right and sometimes completely failed. I have gone to google and found solutions that look close but do not work. I have focused on IF statements and expressions, however, have tried some other formulae that may work with no luck.

Extra Info;

I have attached an example spreadsheet as the other information on the original is commercially sensitive. In columns J to L, I have included what the dates should be based on the rules as set above.

Many thanks for your help;

I would appreciate any help. I am continuing to work on this and if I find the solution I will post for the completion and future 'Googlers'. 

4 Replies
You've given a lot of helpful info, but I'm still not quite understanding the whole. Maybe some of the other Excel experts can decipher all of this; I'm going to need to ask a few more questions to make sure I'm tracking with you. It's what I'd do if we were sitting down face-to-face.

I gather that it's column G where you want this final formula. (Please confirm)
I get that column J is the desired answer, i.e., what should appear as a result of whatever formula is created in G
What I don't get yet is how each rule applies in each row. I.e., what in columns B through F tells me which condition is to be met.

It will help -- this is all very clear in your mind, I know -- it will help if you walk through maybe the first three rows, describing (in words) HOW data in columns B through F lead to the answer in column J....from those verbal descriptions, then, our challenge is to create a single conditional formula that consistently produces the desired result.

Thanks @mathetes that is a good point, it is clear in my mind. I'll do my best to describe this in words.

 

Column A is a starting point so to speak. I am given a form with a date on it, that is when the date of  inspection and when the valid period begins.
On that same form is a date which is put into Column C. This is the date that sets the conditions for how long the inspection will be valid for.
Column D is the current age of the antifoul based on the date difference between TODAY() and Column C. This is the main parameter that sets the conditions for the inspection expiry. If the Date Dif between TODAY and Column C is;

  • Within 3 Months the Inspection is valid for 6 months,
  • Within 6 Months the Inspection is valid for 6 months or until the date in Column F (Calc'd from Col' C and Col' E. Info for Col' E is also collected from the inspection form) reaches 12 months old, which ever comes first.
  • Beyond 12 Months until the date in Column F is reached the inspection lasts for 3 months.

Column F is calc'd using the date supplied for Col' C and Col' E. In some cases this will be what sets the upper limit of the inspection.

 

The info I supplied in Column L, with Col' J being the desired output, is the months the reason why the expiry date is what it is.

You basically repeated your first post. I was looking for step by step through the first three examples, how you got the answer in col J, which means, I guess, how you got the info in column L.

I'm asking you to be VERY basic, explain step by step, what leads to the right answer, for those examples you give in rows 2, 3 and 4. What you've given is the higher level rules, but you've not "applied them" visibly, by which I mean, so that all I (or any other person here) needs to do is translate your words for rows 2, 3 and 4.
best response confirmed by TheLimbix (New Contributor)
Solution

@TheLimbix 

Does this do it?

I have converted to a table to keep the data and formulas in sync.

= MIN(
   EDATE([@[Inspection Date]], IF(today-[@[AntiFoul Application Date]] < 182, 6, 3)),
   [@[Antifoul Expiry]] )