If Formula

%3CLINGO-SUB%20id%3D%22lingo-sub-1934128%22%20slang%3D%22en-US%22%3EIf%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934128%22%20slang%3D%22en-US%22%3EHi%20everyone%2C%3CBR%20%2F%3E%3CBR%20%2F%3EI%E2%80%99m%20trying%20to%20creat%20a%20formula%20that%20calculate%20severance%20reward%20for%20employees%20based%20on%20the%20years%20of%20service%20and%20salary.%20This%20reward%20not%20for%20all%20staff%20only%20for%20people%20with%20low%20wages%20and%20have%20completed%20a%20certain%20years%20of%20service.%3CBR%20%2F%3E%3CBR%20%2F%3EFor%20example%20in%20the%20employee%20salary%20is%20less%20than%202k%20and%20has%20completed%205%20years%20he%20will%20get%203%20months%20salary%20as%20a%20bonus%20if%2010%20years%20will%20get%204%20months%20bonus%20...%20etc.%20I%20came%20up%20with%20formula%20but%20is%20is%20only%20working%20if%20I%20use%20one%20segment%2C%20how%20can%20I%20make%20excel%20calculate%20the%20whole%20formula%20using%20if%20functions%3CBR%20%2F%3E%3CBR%20%2F%3E%3DIF(AND(K13%26gt%3B%3D5%2CK13%26lt%3B10%2CD8%26lt%3B2000)%2CD8*3%2C0)%2CIF(AND(K13%26gt%3B10%2CK13%26lt%3B15%2CD8%26lt%3B2000)%2CD8*4%2C0)%2CIF(AND(K13%26gt%3B%3D15%2CD8%26lt%3B2000)%2CD8*6%2C0)%2CIF(AND(K13%26gt%3B%3D5%2CK13%26lt%3B10%2CD8%26lt%3B2000%2CD8%26lt%3B5000)%2CD8*2%2C0)%2CIF(AND(K13%26gt%3B10%2CK13%26lt%3B15%2CD8%26lt%3B2000%2CD8%26lt%3B5000)%2CD8*3%2C0)%2CIF(AND(K13%26gt%3B15%2CD8%26lt%3B2000%2CD8%26lt%3B5000)%2CD8*4%2C0)%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3CBR%20%2F%3ESorry%20for%20the%20long%20message%3A)%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1934128%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1934167%22%20slang%3D%22en-US%22%3ERe%3A%20If%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934167%22%20slang%3D%22en-US%22%3E%3CP%3EHi%26nbsp%3B%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F882552%22%20target%3D%22_blank%22%3E%40TurkiAlhamed%3C%2FA%3E%2C%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOne%20of%20the%20problem%20with%20your%20formula%20is%20that%20you%20set%20the%20%22else%22%20portion%20of%20all%20your%20%22IF%22%20to%20%220%22.%20Instead%2C%20the%20%22else%22%20portion%20should%20be%20the%20next%20%22IF%22%20(hopefully%20it%20make%20sense)%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(AND(K13%26gt%3B%3D5%2CK13%26lt%3B10%2CD8%26lt%3B2000)%2CD8*3%2CIF(AND(K13%26gt%3B10%2CK13%26lt%3B15%2CD8%26lt%3B2000)%2CD8*4%2CIF(AND(K13%26gt%3B%3D15%2CD8%26lt%3B2000)%2CD8*6%2CIF(AND(K13%26gt%3B%3D5%2CK13%26lt%3B10%2CD8%26lt%3B2000%2CD8%26lt%3B5000)%2CD8*2%2CIF(AND(K13%26gt%3B10%2CK13%26lt%3B15%2CD8%26lt%3B2000%2CD8%26lt%3B5000)%2CD8*3%2CIF(AND(K13%26gt%3B15%2CD8%26lt%3B2000%2CD8%26lt%3B5000)%2CD8*4%2C0))))))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3EThat%20said%2C%20the%20last%203%20%22IF%2FAND%22%20are%20evaluating%20cell%20D18%20to%20be%20lower%20then%202000%20and%20lower%20then%205000.%20If%20D18%20is%20lower%20then%202000%2C%20consequently%20it%20is%20lower%20then%205000%20so%20you%20don't%20need%20to%20check%20the%20lower%20then%202000.%20Here's%20a%20revised%20version%20of%20your%20formula%20with%20this%20adjustment...%3C%2FP%3E%3CPRE%20class%3D%22lia-code-sample%20language-applescript%22%3E%3CCODE%3E%3DIF(AND(K13%26gt%3B%3D5%2CK13%26lt%3B10%2CD8%26lt%3B2000)%2CD8*3%2CIF(AND(K13%26gt%3B10%2CK13%26lt%3B15%2CD8%26lt%3B2000)%2CD8*4%2CIF(AND(K13%26gt%3B%3D15%2CD8%26lt%3B2000)%2CD8*6%2CIF(AND(K13%26gt%3B%3D5%2CK13%26lt%3B10%2CD8%26lt%3B5000)%2CD8*2%2CIF(AND(K13%26gt%3B10%2CK13%26lt%3B15%2CD8%26lt%3B5000)%2CD8*3%2CIF(AND(K13%26gt%3B15%2CD8%26lt%3B5000)%2CD8*4%2C0))))))%3C%2FCODE%3E%3C%2FPRE%3E%3CP%3E%26nbsp%3B%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1934208%22%20slang%3D%22en-US%22%3ERe%3A%20If%20Formula%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1934208%22%20slang%3D%22en-US%22%3E%3CP%3EHi%3CBR%20%2F%3E%3CBR%20%2F%3EThank%20you%20for%20your%20reply%20and%20help%2C%20i%20just%20tried%20it%20and%20it%20is%20working%2C%20as%20for%20the%20last%203%20ifs%2C%20it%20is%20supposed%20to%20be%20%26gt%3B2000%20and%20%26lt%3B5000%2C%20and%20I%20updated%20that%20as%20well.%3CBR%20%2F%3E%3CBR%20%2F%3EVery%20grateful%20for%20you%20help.%3C%2FP%3E%3C%2FLINGO-BODY%3E
New Contributor
Hi everyone,

I’m trying to creat a formula that calculate severance reward for employees based on the years of service and salary. This reward not for all staff only for people with low wages and have completed a certain years of service.

For example in the employee salary is less than 2k and has completed 5 years he will get 3 months salary as a bonus if 10 years will get 4 months bonus ... etc. I came up with formula but is is only working if I use one segment, how can I make excel calculate the whole formula using if functions

=IF(AND(K13>=5,K13<10,D8<2000),D8*3,0),IF(AND(K13>10,K13<15,D8<2000),D8*4,0),IF(AND(K13>=15,D8<2000),D8*6,0),IF(AND(K13>=5,K13<10,D8<2000,D8<5000),D8*2,0),IF(AND(K13>10,K13<15,D8<2000,D8<5000),D8*3,0),IF(AND(K13>15,D8<2000,D8<5000),D8*4,0)



Sorry for the long message:)
2 Replies

Hi @TurkiAlhamed,

 

One of the problem with your formula is that you set the "else" portion of all your "IF" to "0". Instead, the "else" portion should be the next "IF" (hopefully it make sense)

=IF(AND(K13>=5,K13<10,D8<2000),D8*3,IF(AND(K13>10,K13<15,D8<2000),D8*4,IF(AND(K13>=15,D8<2000),D8*6,IF(AND(K13>=5,K13<10,D8<2000,D8<5000),D8*2,IF(AND(K13>10,K13<15,D8<2000,D8<5000),D8*3,IF(AND(K13>15,D8<2000,D8<5000),D8*4,0))))))

That said, the last 3 "IF/AND" are evaluating cell D18 to be lower then 2000 and lower then 5000. If D18 is lower then 2000, consequently it is lower then 5000 so you don't need to check the lower then 2000. Here's a revised version of your formula with this adjustment...

=IF(AND(K13>=5,K13<10,D8<2000),D8*3,IF(AND(K13>10,K13<15,D8<2000),D8*4,IF(AND(K13>=15,D8<2000),D8*6,IF(AND(K13>=5,K13<10,D8<5000),D8*2,IF(AND(K13>10,K13<15,D8<5000),D8*3,IF(AND(K13>15,D8<5000),D8*4,0))))))

  

 

 

Hi

Thank you for your reply and help, i just tried it and it is working, as for the last 3 ifs, it is supposed to be >2000 and <5000, and I updated that as well.

Very grateful for you help.