Wednesday, November 28, 2012

IF statement in BEx queries

Using IF statement is very convenient how to evaluate the data. As usually BW developers are coming with programming background it is very obvious that they are looking into such statements. Although it is not very obvious from the very modest menu of functions in BEx’s formulas IF is possible it is just not easy to realize how this can be achieved.

Logic how to implement IF in BE’x formulas is following:

(  cond1  ) * ( result_if_cond1_is_tru ) + (  cond2 ) * (  result_if_cond2_is_tru )

+    means    ELSE

*    means    THEN

You can combine several conditions with AND operator. For example here’s simple IF-ELSE; in case KF1 is greater then KF2 put KF3 as result else put KF4 as result:

( KF1 > KF2) * KF3 + ( KF1 <= KF2) * KF4

Official documentation about so called “Conditional Calculations (IF-THEN-ELSE)” can be found here:

No comments: