Formula is not working and is lengthy

%3CLINGO-SUB%20id%3D%22lingo-sub-2020614%22%20slang%3D%22en-US%22%3EFormula%20is%20not%20working%20and%20is%20lengthy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2020614%22%20slang%3D%22en-US%22%3E%3CP%3EUsing%20below%20formula%20to%20count%20the%20leaves%20between%20the%20dates.%20But%20i%20do%20not%20know%20what%20is%20wrong%20with%20my%20formula%20that%20why%20its%20not%20making%20calculations%20whereas%20it%20is%20accurate.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eand%20i%20am%20also%20looking%20to%20shorten%20this%20formula.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3Eanybody%20please%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-2020614%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-2020857%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20is%20not%20working%20and%20is%20lengthy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2020857%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F913551%22%20target%3D%22_blank%22%3E%40TheOcean%3C%2FA%3E%26nbsp%3BOh%20my!%20What%20a%20formula.%20I%20don't%20even%20dare%20to%20start%20analysing%20it.%20Rather%20than%20revising%20the%20formula%2C%20I%20would%20like%20to%20suggest%20that%20you%20change%20the%20way%20you%20capture%20leave%20data.%20Use%20one%20table%20and%20then%20%26nbsp%3Bcreate%20whatever%20summary%20report%20you%20want%2Fneed%20from%20it.%20Sheet2%20in%20the%20attached%20(your)%20sheet%20is%20just%20an%20example%20of%20what%20is%20possible%2C%20using%20a%20pivot%20table.%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2020859%22%20slang%3D%22en-US%22%3ERe%3A%20Formula%20is%20not%20working%20and%20is%20lengthy%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2020859%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F913551%22%20target%3D%22_blank%22%3E%40TheOcean%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThat%20may%20be%20the%20longest%20formula%20I've%20ever%20seen.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThere%20is%20a%20reason%20(actually%20there%20are%20more%20than%20one%20reason)%20why%20many%20textbooks%20on%20Excel%20recommend%20strongly%20against%20writing%20formulas%20that%20are%20long.%20You're%20in%20the%20midst%20of%20learning%20some%20of%20them.%20Primary%20reason%2C%20though%2C%20is%20this%3A%20It's%20extremely%20difficult%20to%20diagnose%20the%20cause%20when%20a%20formula%20stops%20working%20(or%20never%20really%20works%20in%20the%20first%20place).%20This%20is%20especially%20true%20if%20somebody%20else%20wrote%20the%20formula.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CUL%3E%3CLI%3E%3CU%3E%3CSTRONG%3EOne%20Solution%3A%20use%20helper%20columns.%3C%2FSTRONG%3E%3C%2FU%3E%20Translation%2C%20break%20it%20down%20into%20sub-functions%20or%20formulas.%20Don't%20try%20to%20pack%20it%20all%20into%20one%20unintelligible%20formula.%3C%2FLI%3E%3CLI%3E%3CU%3E%3CSTRONG%3EA%20%3CFONT%20color%3D%22%23FF0000%22%3Emore%20fundamental%2C%20factor%3A%20the%20overall%20design%3C%2FFONT%3E%20of%20your%20workbook%20is%20a%20major%20contributor%20to%20the%20problem.%3C%2FSTRONG%3E%3C%2FU%3E%20Without%20knowing%20the%20history%20of%20this%2C%20just%20looking%20at%20it%20leads%20me%20to%20the%20supposition%20that%20you've%20taken%20what%20used%20to%20be%20a%20paper-based%20tracking%20system%20and%20%22automated%20it%22%20by%20continuing%20to%20use%20the%20paper-based%20paradigm%20of%20record%20keeping%20(one%20sheet%20per%20month%2C%20one%20cell%20per%20day%20per%20employee%20in%20each%20monthly%20sheet%2C%20entering%20an%20%22L%22%20representing%20%22leave%22%20into%20those%20cells)....then%20asking%20Excel%20to%20count%20'em.%3CUL%3E%3CLI%3EThat's%20just%20NOT%20an%20effective%20way%20to%20accomplish%20the%20business%20need%20using%20Excel.%3CUL%3E%3CLI%3EYou'd%20be%20much%20better%20served%20by%20a%20re-design%20that%20tracks%20attendance%2C%20vacation%2C%20leaves%2C%20whatever...as%20a%20single%20database.%3C%2FLI%3E%3CLI%3EAnd%20then%20learn%20how%20to%20use%20something%20like%20the%20Pivot%20Table%20to%20produce%20your%20count.%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3CLI%3EAt%20this%20point%2C%20if%20I%20were%20meeting%20with%20you%20face-to-fact%2C%20%3CU%3EI'd%20recommend%20%3CFONT%20color%3D%22%23FF0000%22%3Eagainst%3C%2FFONT%3E%20trying%20to%20fix%20this%20dysfunctional%20formula%3C%2FU%3E--which%20is%20akin%20to%20just%20finding%20a%20bigger%20bandage%20to%20cover%20a%20wound.%20Instead%2C%20work%20to%20achieve%20a%20deeper%20solution.%20%3CEM%3EDon't%20just%20relieve%20the%20symptoms%3B%20find%20the%20cure%20for%20the%20underlying%20condition.%3C%2FEM%3E%3C%2FLI%3E%3C%2FUL%3E%3C%2FLI%3E%3C%2FUL%3E%3CP%3EIs%20such%20an%20approach--a%20radical%20redesign--thinkable%3F%20If%20so%2C%20you'll%20need%20to%20provide%20a%20deeper%20description%20of%20what%20the%20overall%20process%20is%20intended%20to%20achieve.%20Are%20you%20also%20tracking%20other%20aspects%20of%20employee%20history%2C%20for%20example%3F%20What%20is%20the%20bigger%20picture%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIf%20you're%20not%20open%20to%20a%20redesign%2C%20then%20use%20%22helper%20columns%22%20and%20break%20the%20formula%20you%20have%20into%20sub-formulas.%20You%20clearly%20know%20how%20to%20write%20working%20formulas%3B%20you've%20just%20made%20the%20mistake%20of%20trying%20to%20pack%20all%20of%20the%20conditions%20into%20a%20single%20formula%20and%20are%20now%20experiencing%20the%20inevitable%20result--unintelligibility.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor

Using below formula to count the leaves between the dates. But i do not know what is wrong with my formula that why its not making calculations whereas it is accurate.

 

and i am also looking to shorten this formula.

 

anybody please help.

2 Replies

@TheOcean Oh my! What a formula. I don't even dare to start analysing it. Rather than revising the formula, I would like to suggest that you change the way you capture leave data. Use one table and then  create whatever summary report you want/need from it. Sheet2 in the attached (your) sheet is just an example of what is possible, using a pivot table. 

@TheOcean 

 

That may be the longest formula I've ever seen.

 

There is a reason (actually there are more than one reason) why many textbooks on Excel recommend strongly against writing formulas that are long. You're in the midst of learning some of them. Primary reason, though, is this: It's extremely difficult to diagnose the cause when a formula stops working (or never really works in the first place). This is especially true if somebody else wrote the formula.

 

  • One Solution: use helper columns. Translation, break it down into sub-functions or formulas. Don't try to pack it all into one unintelligible formula.
  • A more fundamental, factor: the overall design of your workbook is a major contributor to the problem. Without knowing the history of this, just looking at it leads me to the supposition that you've taken what used to be a paper-based tracking system and "automated it" by continuing to use the paper-based paradigm of record keeping (one sheet per month, one cell per day per employee in each monthly sheet, entering an "L" representing "leave" into those cells)....then asking Excel to count 'em.
    • That's just NOT an effective way to accomplish the business need using Excel.
      • You'd be much better served by a re-design that tracks attendance, vacation, leaves, whatever...as a single database.
      • And then learn how to use something like the Pivot Table to produce your count.
    • At this point, if I were meeting with you face-to-fact, I'd recommend against trying to fix this dysfunctional formula--which is akin to just finding a bigger bandage to cover a wound. Instead, work to achieve a deeper solution. Don't just relieve the symptoms; find the cure for the underlying condition.

Is such an approach--a radical redesign--thinkable? If so, you'll need to provide a deeper description of what the overall process is intended to achieve. Are you also tracking other aspects of employee history, for example? What is the bigger picture?

 

If you're not open to a redesign, then use "helper columns" and break the formula you have into sub-formulas. You clearly know how to write working formulas; you've just made the mistake of trying to pack all of the conditions into a single formula and are now experiencing the inevitable result--unintelligibility.