IF-function for date in excel, some dates becomes 0

%3CLINGO-SUB%20id%3D%22lingo-sub-1488474%22%20slang%3D%22en-US%22%3EIF-function%20for%20date%20in%20excel%2C%20some%20dates%20becomes%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488474%22%20slang%3D%22en-US%22%3E%3CP%3EHi!%3C%2FP%3E%3CP%3EI%20am%20doing%20a%20payable%20in%20excel%20for%20an%20assignment.%20I'm%20using%20the%20IF-function%20to%20calculate%20what%20the%20date%20should%20be%20in%20the%20column%20named%20date%20of%20payment.%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20is%20the%20function%20I%20have%20created%3A%26nbsp%3B%3DOM(B6%3D420%3BC6%2B%24O%246%3BOM(B6%3D500%3BC6%2B%24O%247)*(OM(B6%3D150%3B(C6%2B%24O%248)*(OM(B6%3D320%3B(C6%2B%24O%249)%3B0)))))%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EWhen%20I%20double-click%20in%20the%20right%20bottom%20corner%20to%20make%20the%20function%20go%20all%20the%20way%20down%20in%20the%20spreadsheet%20for%20as%20many%20rows%20I%20am%20using%2C%20some%20dates%20is%20correct%20and%20some%20are%20not.%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EFor%20example%3A%20in%20one%20column%20it%20says%202020-05-30%20and%20if%20the%20invoice%20came%20to%20the%20account%20420%20it%20should%20add%2030%20days%20to%20the%20dates%20and%20fill%20it%20in%20in%20the%20column%20named%20date%20of%20payment.%26nbsp%3B%3CBR%20%2F%3EIn%20some%20rows%20the%20dates%20becomes%201900-01-00.%20Why%20does%20the%20function%20work%20on%20some%20dates%20but%20not%20others%3F%20The%20function%20is%20the%20same%20for%20all%20rows...%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1488474%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%20on%20Mac%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1488524%22%20slang%3D%22en-US%22%3ERe%3A%20IF-function%20for%20date%20in%20excel%2C%20some%20dates%20becomes%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488524%22%20slang%3D%22en-US%22%3E%3CP%3EHi%20Akila%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ESome%20dates%20are%20returning%200%20because%20the%20first%20part%20of%20your%20formula%20%3CFONT%20color%3D%22%233366FF%22%3EIF(B13%3D420%2CC13%2B%24O%246%2CIF(B13%3D500%2CC13%2B%24O%247))%3C%2FFONT%3E%26nbsp%3Bis%20restricted%20to%20only%20two%20values.%20According%20to%20your%20workbook%2C%20you%20have%20four%20values%20in%20Column%20B%20(500%2C420%2C150%20and%20320)%20but%20your%20formula%20is%20only%20referencing%20420%20and%20500.%20So%20when%20it%20gets%20to%20a%20row%20that%20has%20either%20150%20or%20320%2C%20the%20first%20part%20of%20the%20formula%20will%20return%200%20which%20is%20why%20some%20of%20the%20dates%20becomes%200.%3CBR%20%2F%3E%3CBR%20%2F%3EThe%20same%20thing%20also%20for%20the%20second%20part%20of%20your%20formula%26nbsp%3B%3CFONT%20color%3D%22%233366FF%22%3E(IF(B6%3D150%2C(C6%2B%24O%248)*(IF(B6%3D320%2C(C6%2B%24O%249)%2C0)))))%3B%26nbsp%3B%3CFONT%20color%3D%22%23000000%22%3Eit%20is%20only%20referencing%20two%20values.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20will%20advise%20that%20you%20adjust%20your%20formula%20to%20cover%20the%20four%20values%20in%20Column%20B%20or%20use%20a%20a%20combination%20of%20IF%20and%20OR%20Function.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20hope%20this%20helps.%3C%2FFONT%3E%3C%2FFONT%3E%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1488545%22%20slang%3D%22en-US%22%3ERe%3A%20IF-function%20for%20date%20in%20excel%2C%20some%20dates%20becomes%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488545%22%20slang%3D%22en-US%22%3E%3CP%3EThank%20you%20so%20much%20for%20your%20answer%2C%20and%20quick%20reply!%3CBR%20%2F%3ESo%20basically%2C%20what%20I%20have%20done%20is%20that%20I%20have%20divided%20the%20formula%20into%20two%20parts%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20will%20try%20to%20figure%20it%20out%20on%20my%20own%2C%20but%20if%20you%20have%20time%20to%20help%2C%20how%20do%20I%20fix%20the%20problem%20without%20having%20to%20insert%20a%20second%20formula%20like%20OR%3F%20I%20think%20that%20is%20too%20advanced%20for%20me.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3ERegards!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1488560%22%20slang%3D%22en-US%22%3ERe%3A%20IF-function%20for%20date%20in%20excel%2C%20some%20dates%20becomes%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488560%22%20slang%3D%22en-US%22%3E%3CP%3EI%20solved%20it%20myself!%20I%20needed%20to%20use%20%2B%20between%20the%20arguments%20in%20the%20formula!%20Thanks%20again%20for%20your%20reply%20and%20the%20help%20to%20solving%20my%20issue!!!%20%3CLI-EMOJI%20id%3D%22lia_slightly-smiling-face%22%20title%3D%22%3Aslightly_smiling_face%3A%22%3E%3C%2FLI-EMOJI%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1488578%22%20slang%3D%22en-US%22%3ERe%3A%20IF-function%20for%20date%20in%20excel%2C%20some%20dates%20becomes%200%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1488578%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20Akila%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EYou%20can%20use%20the%20IFS%20function%20to%20fix%20the%20problem%20-%20see%20below.%3C%2FP%3E%3CP%3E%3CFONT%20color%3D%22%233366FF%22%3E%3DIFS(B6%3D420%2CC6%2B%24O%246%2CB6%3D500%2CC6%2B%24O%247%2CB6%3D150%2CC6%2B%24O%248%2CB6%3D320%2CC6%2B%24O%249)%3C%2FFONT%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThis%20should%20work%20fine%20and%20you%20do%20not%20need%20the%20second%20part%20of%20the%20formula%20again.%3CBR%20%2F%3E%3CBR%20%2F%3EI%20hope%20this%20helps.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
New Contributor

Hi!

I am doing a payable in excel for an assignment. I'm using the IF-function to calculate what the date should be in the column named date of payment. 

This is the function I have created: =OM(B6=420;C6+$O$6;OM(B6=500;C6+$O$7)*(OM(B6=150;(C6+$O$8)*(OM(B6=320;(C6+$O$9);0)))))

 

When I double-click in the right bottom corner to make the function go all the way down in the spreadsheet for as many rows I am using, some dates is correct and some are not. 

 

For example: in one column it says 2020-05-30 and if the invoice came to the account 420 it should add 30 days to the dates and fill it in in the column named date of payment. 
In some rows the dates becomes 1900-01-00. Why does the function work on some dates but not others? The function is the same for all rows... 

4 Replies
Highlighted

Hi Akila,

 

Some dates are returning 0 because the first part of your formula IF(B13=420,C13+$O$6,IF(B13=500,C13+$O$7)) is restricted to only two values. According to your workbook, you have four values in Column B (500,420,150 and 320) but your formula is only referencing 420 and 500. So when it gets to a row that has either 150 or 320, the first part of the formula will return 0 which is why some of the dates becomes 0.

The same thing also for the second part of your formula (IF(B6=150,(C6+$O$8)*(IF(B6=320,(C6+$O$9),0))))); it is only referencing two values.

I will advise that you adjust your formula to cover the four values in Column B or use a a combination of IF and OR Function.

I hope this helps.

Highlighted

Thank you so much for your answer, and quick reply!
So basically, what I have done is that I have divided the formula into two parts?

 

I will try to figure it out on my own, but if you have time to help, how do I fix the problem without having to insert a second formula like OR? I think that is too advanced for me.

 

Regards!

I solved it myself! I needed to use + between the arguments in the formula! Thanks again for your reply and the help to solving my issue!!!  

Highlighted

Hello Akila,

 

You can use the IFS function to fix the problem - see below.

=IFS(B6=420,C6+$O$6,B6=500,C6+$O$7,B6=150,C6+$O$8,B6=320,C6+$O$9)

 

This should work fine and you do not need the second part of the formula again.

I hope this helps.