Skip to Content
avatar image
Former Member

Complex If else statement

Need to write a statement.Please help.

A and B,B1,B2 are Key Figures

Condition 1:  A> B

Condition 2 : A< B

Condition 3:  A==B

Condition 4:  B=-B

Created a formula i.e CKF as  C.So formula should be like this below.But i am not getting the desired output.

(Condition==1) * NOERR (NODIV (  ( A/B ) ) )  * 30  + (Condition 2==1) * NOERR  ( NODIV(  ( ( A- B-B1)/B2 * 30 + 60) ) )  + (Condition3==1) * NOERR (NODIV( (A/B)))* 30 +

(Condition4==1) * 0

Result i want to get is :

If A is less than B i.e If Condition 1 then A/B multiply by 30 else if A is greater than B i.e  If Condition 2 then (A-B-B1/B2)*30+60 else if A is equals B i.e If Condition 3 then A/B multiply by 30 else if B`s value comes in negative i.e If Condition 4 then 0.

Please suggest how to write.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Jan 01, 2015 at 10:25 AM

    Hi Adithya,

    Whe you have complex IF ELSE Formulae...then BREAK them up into small peices so that you know where hte issue is..

    CKF1 =(Condition==1) * NOERR (NODIV (  ( A/B ) ) )  * 30 

    CKF2=(Condition 2==1) * NOERR  ( NODIV(  ( ( A- B-B1)/B2 * 30 + 60) ) ) 

    CKF3=(Condition3==1) * NOERR (NODIV( (A/B)))* 30

    CKF4=(Condition4==1) * 0

    Then add them up

    CKF5=CKF1+CKF2+CKF3+CKF4.

    For your own testing display all the CKFs.all 5 and during final Transport ... hide the CKF1/CKF2/CKF3/CKF4 and display CKF5

    rgds

    SVU

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 30, 2014 at 05:09 PM

    Hi

    Please once try with the below one.

    (Condition==1) * (NOERR (NODIV (  ( A/B ) ) )  * 30 ) + (Condition 2==1) * (NOERR  ( NODIV(  ( ( A- B-B1)/B2 * 30 + 60)) ) )  + (Condition3==1) *( NOERR (NODIV( (A/B)))* 30 + 60 )

    (Condition4==1) * 0

    Just keep the condition value in the bracket and try once.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 01, 2015 at 10:44 AM


    Hi,

    Condition 4:  B=-B i.e. if B is negative Condition 4 must be outermost in the nested if. If its priority is highest.  I understood is correct then the solution given by @SUV 123 can be modified as below;

    CKF1 = A>B * NOERR (NODIV (  ( A/B ) ) )  * 30 

    CKF2 = A<B * NOERR  ( NODIV(  ( ( A- B-B1)/B2 * 30 + 60) ) ) 

    CKF3 = A=B * NOERR (NODIV( (A/B)))* 30

    CKF4  -  B<0 * 0 + B>0 * CKF1+CKF2+CKF3

    Hope this gives you desired solution.

    Regards,

    Sucheta

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 01, 2015 at 11:52 AM

    Hi Aditya,

    if A =< B.

       C = (A/B) * 30.

    elseif A > B.

      C = (A-B-B1/B2)*30+60

    elseif B < 0.

      C = 0.

    endif.

    Hope it will help .

    Regards

    Rounak 😊

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jan 02, 2015 at 06:46 AM

    Issue resolved.It was the bracked issue.All your posts helped 😊 The NOERR,NODIV brackets will close at *30 only.That was the issue.

    Add comment
    10|10000 characters needed characters exceeded