0

# IF Else condition in SAP BW BEx Query

Mar 17, 2017 at 02:16 PM

124

Former Member

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

Former Member Mar 30, 2017 at 08:33 PM
0

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

Share
Loed Despuig Apr 01, 2017 at 04:49 AM
0

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

Share