SOLVED

Nested IF and OR

%3CLINGO-SUB%20id%3D%22lingo-sub-2754713%22%20slang%3D%22en-US%22%3ENested%20IF%20and%20OR%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2754713%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20everyone%3C%2FP%3E%3CP%3EI%20have%20successfully%20created%20a%20nested%20IF%20with%20AND%20statement%2C%20but%20realized%20after%20completion%20that%20I%20forgot%20to%20check%20for%20a%20new%20variable.%3C%2FP%3E%3CP%3EWhen%20I%20try%20to%20add%20the%20new%20variable%26nbsp%3B%20into%20the%20equation%20it%20keeps%20failing%3C%2FP%3E%3CP%3EThe%20working%20formula%20looks%20for%26nbsp%3BSEVERITY%2C%20Prime%2C%20Off%20Shift%2C%20and%20Total%20Onsite%20Time.%2C%20then%20calculate%20whether%20service%20teck%20onsite%20miss%3C%2FP%3E%3CP%3EI%20am%20trying%20to%20add%20new%20variable%20-%20onsite%20date%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHere%20is%20the%20working%20formula%2C%20which%20outputs%20either%20Y%20or%20N%20for%20missed%20onsite%20time%2C%20refer%20to%20column%20AJ%3C%2FP%3E%3CP%3E%3DIF(AND(E2%3D1%2CAB2%3D%22Prime%22%2CAI2%26lt%3B%3D2)%2C%22N%22%2CIF(AND(E2%3D1%2CAB2%3D%22Prime%22%2CAI2%26gt%3B2)%2C%22Y%22%2CIF(AND(E2%3D1%2CAB2%3D%22Off%20Shift%22%2CAI2%26lt%3B%3D3)%2C%22N%22%2CIF(AND(E2%3D1%2CAB2%3D%22Off%20Shift%22%2CAI2%26gt%3B%3D3)%2C%22Y%22%2C%3CBR%20%2F%3EIF(AND(E2%3D2%2CAB2%3D%22Prime%22%2CAI2%26lt%3B%3D4)%2C%22N%22%2CIF(AND(E2%3D2%2CAB2%3D%22Prime%22%2CAI2%26gt%3B%3D4)%2C%22Y%22%2CIF(AND(E2%3D2%2CAB2%3D%22Off%20Shift%22%2CAI2%26lt%3B%3D8)%2C%22N%22%2CIF(AND(E2%3D2%2CAB2%3D%22Off%20Shift%22%2CAI2%26gt%3B%3D8)%2C%22Y%22%2C%3CBR%20%2F%3EIF(AND(E2%3D3%2CAB2%3D%22Prime%22%2CAI2%26lt%3B%3D24)%2C%22N%22%2CIF(AND(E2%3D3%2CAB2%3D%22Prime%22%2CAI2%26gt%3B%3D24)%2C%22Y%22%2CIF(AND(E2%3D3%2CAB2%3D%22Off%20Shift%22%2CAI2%26lt%3B%3D24)%2C%22N%22%2CIF(AND(E2%3D3%2CAB2%3D%22Off%20Shift%22%2CAI2%26gt%3B%3D24)%2C%22Y%22%2C%3CBR%20%2F%3EIF(AND(E2%3D4%2CAB2%3D%22Prime%22%2CAI2%26lt%3B%3D99)%2C%22N%22%2CIF(AND(E2%3D4%2CAB2%3D%22Prime%22%2CAI2%26gt%3B%3D99)%2C%22Y%22%2CIF(AND(E2%3D4%2CAB2%3D%22Off%20Shift%22%2CAI2%26lt%3B%3D99)%2C%22N%22%2CIF(AND(E2%3D4%2CAB2%3D%22Off%20Shift%22%2CAI2%26gt%3B%3D99)%2C%22Y%22))))))))))))))))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EColunmn%20X%20contains%20the%20variable%20that%20I%20forget%20to%20initially%20check%20for%20----%20onsite%20service%20technician%20date.%3C%2FP%3E%3CP%3ENot%20all%20calls%20require%20service%20teck%20to%20go%20onsite%2C%20so%20if%20the%20service%20teck%20onsite%20date%20in%20column%20X%20shows%201%2F0%2F1900%2C%20this%20means%20that%20service%20never%20had%20to%20go%20onsite%20to%20resolve%20the%20issue%2C%20therefore%20there%20could%20not%20be%20a%20missed%20onsite%20time%2C%20Calls%20flagged%20with%20onsite%20date%201%2F0%2F1900%20automatically%20should%20have%20the%20missed%20onsite%20time%20flag%20in%20column%20AJ%20set%20to%20N.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ECan%20anyone%20assist%20in%20updating%20my%20formula%20above%20to%20include%20a%20check%20for%20column%20X%2C%20to%20see%20if%20onsite%20date%20is%20equal%20to%201%2F0%2F1900%20%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20tried%20adding%20this%20check%20but%20the%20formula%20fails.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThe%20logic%20should%20be%20to%20check%20for%20this%20onsite%20date%20first%2C%20and%20if%20the%20date%20is%20not%201%2F0%2F1900%2C%20then%20proceed%20with%20the%20remaining%20logic%20in%20the%20formula.%20If%20the%20check%20for%201%2F0%2F1900%20finds%20a%20match%2C%20the%20mark%20column%20AJ%20as%20N%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20have%20attached%20a%20test%20file%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EPlease%20disregard%20the%20current%20formulas%20in%20column%20AJ%2C%20in%20the%20excel%20file%20as%20I%20had%20to%20manually%20process%20each%20line%20to%20get%20the%20right%20output.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ELouis%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2754713%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2754842%22%20slang%3D%22en-US%22%3ERe%3A%20Nested%20IF%20and%20OR%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2754842%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1157271%22%20target%3D%22_blank%22%3E%40loumar1%3C%2FA%3E%26nbsp%3BSince%20the%20numerical%20value%20for%20the%20date%20January%200%2C%201900%20equals%20to%20zero%2C%20you%20can%20wrap%20your%20entire%20formula%20in%20one%20more%20IF%20statement.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%3DIF(%20X2%3D0%2C%200%20%2C%20%3CYOUR%20formula%3D%22%22%20with%3D%22%22%20the%3D%22sign%22%3E%20)%3C%2FYOUR%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Hi everyone

I have successfully created a nested IF with AND statement, but realized after completion that I forgot to check for a new variable.

When I try to add the new variable  into the equation it keeps failing

The working formula looks for SEVERITY, Prime, Off Shift, and Total Onsite Time., then calculate whether service teck onsite miss

I am trying to add new variable - onsite date

 

Here is the working formula, which outputs either Y or N for missed onsite time, refer to column AJ

=IF(AND(E2=1,AB2="Prime",AI2<=2),"N",IF(AND(E2=1,AB2="Prime",AI2>2),"Y",IF(AND(E2=1,AB2="Off Shift",AI2<=3),"N",IF(AND(E2=1,AB2="Off Shift",AI2>=3),"Y",
IF(AND(E2=2,AB2="Prime",AI2<=4),"N",IF(AND(E2=2,AB2="Prime",AI2>=4),"Y",IF(AND(E2=2,AB2="Off Shift",AI2<=8),"N",IF(AND(E2=2,AB2="Off Shift",AI2>=8),"Y",
IF(AND(E2=3,AB2="Prime",AI2<=24),"N",IF(AND(E2=3,AB2="Prime",AI2>=24),"Y",IF(AND(E2=3,AB2="Off Shift",AI2<=24),"N",IF(AND(E2=3,AB2="Off Shift",AI2>=24),"Y",
IF(AND(E2=4,AB2="Prime",AI2<=99),"N",IF(AND(E2=4,AB2="Prime",AI2>=99),"Y",IF(AND(E2=4,AB2="Off Shift",AI2<=99),"N",IF(AND(E2=4,AB2="Off Shift",AI2>=99),"Y"))))))))))))))))

 

Colunmn X contains the variable that I forget to initially check for ---- onsite service technician date.

Not all calls require service teck to go onsite, so if the service teck onsite date in column X shows 1/0/1900, this means that service never had to go onsite to resolve the issue, therefore there could not be a missed onsite time, Calls flagged with onsite date 1/0/1900 automatically should have the missed onsite time flag in column AJ set to N.

 

Can anyone assist in updating my formula above to include a check for column X, to see if onsite date is equal to 1/0/1900 ?

 

I tried adding this check but the formula fails.

 

The logic should be to check for this onsite date first, and if the date is not 1/0/1900, then proceed with the remaining logic in the formula. If the check for 1/0/1900 finds a match, the mark column AJ as N,

 

I have attached a test file

 

Please disregard the current formulas in column AJ, in the excel file as I had to manually process each line to get the right output.

 

Louis

 

2 Replies
best response confirmed by loumar1 (New Contributor)
Solution

@loumar1 Since the numerical value for the date January 0, 1900 equals to zero, you can wrap your entire formula in one more IF statement.

 

=IF( X2=0, "Not applicable" , <your formula with the = sign> )

 

 

Thank you very much, I just tried your recommendation and it worked.
I thought I had tried your suggestion previously, but was getting errors

Thank you