Skip to Content
avatar image
Former Member

IF Else condition in SAP BW BEx Query

Hi All,

Can anyone please brief me below logic.i am bit confused on below logic in sap bex query formula

((A==0)*1+0)*(B-C)

with warm regards,

Giri

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Mar 30, 2017 at 08:33 PM

    Hi Giri,

    a condition is 1 if it's true, otherwise 0. In your example:

    if content of A = 0, the condition is true (equal 1) and the result will be (1*1+0)*(B-C) = B-C.

    if content of A <> 0, the condition is false (equal 0) and the result will be (0*1+0)*(B-C) = 0.

    You can have the same result with the following formula: (A==0) * (B-C).

    In general, if-then-else is made in Bex in this way:

    if A = x
     then B
    elseif A = y
     then C
    else D

    in Bex

    (A==x)*B + (A==y)*C + (A<>x * A<>y)*D

    Best regards,

    Antonio

    Add comment
    10|10000 characters needed characters exceeded

  • Apr 01, 2017 at 04:49 AM

    Hi,

    Antonio's explanation above is correct.

    You can just use his formula.

    (A==0) * (B-C)

    But sometimes having multiple elements.

    So what you can do is store first the B-C in a FORMULA.

    TEST_FORMULA = B - C

    Then apply it to your condition formula.

    (A==0) * TEST_FORMULA

    Regards,

    Loed

    Add comment
    10|10000 characters needed characters exceeded