Conditional Commands

Use the conditional commands in Essbase calculation scripts to control the flow of events in formulas. You can control which formulas are executed within a calculation, test conditions, and calculate a formula based on the result of the test.

When you use an IF statement as part of a member formula in a calc script, you need to:

  • Associate it with a single member

  • Enclose it in parentheses

For example:

Profit (IF (Sales > 100)
   Profit = (Sales - COGS) * 2;
ELSE
   Profit = (Sales - COGS) * 1.5;
ENDIF;);

Essbase cycles through the database, performing the following calculations:

  1. The IF statement checks to see if the value of Sales for the current member combination is greater than 100.

  2. If Sales is greater than 100, Essbase subtracts the value in COGS from the value in Sales, multiplies it by 2, and places the result in Profit.

  3. If Sales is less than, or equal to 100, Essbase subtracts the value in COGS from the value in Sales, multiplies it by 1.5, and places the result in Profit.

The entire IF ... ENDIF statement is enclosed in parentheses and associated with the Profit member.