UNIT 3 Calculation Script Architecture Topics • • • • • • • When to use calc scripts Calc Script Editor and online help Database, dimension and member calculations Focus calculations Generate member lists Boolean functions Mathematical functions Introducing Calc Scripts • Components of calc scripts • Calc Script Editor and online Help • Commands and functions Using Calc Script Editor (Demo) Using Essbase Documentation (Demo) • Essbase manuals • Product online Help • HTML formatted documentation • Technical Reference Exercise 3-1: Explore Calc Script Editor and Online Help Exploring Essbase Calc Script Functionality • • • • • • • Functional command and functions Control flow commands (focus) Macro functions Conditional commands Boolean functions Operators Math functions Using Functional Commands • • • • CALC ALL CALC DIM MEMBER CALC Other CALC script commands Calculating the Database Using CALC ALL • Entire database is calculated. • Data is calculated based on outline consolidations and member formulas. • Syntax: CALC ALL [EXCEPT DIM(dimList)| MBR(mbrList)]; (CALC ALL) Low Level data loaded Calculating Dimensions Using CALC DIM • Calculates a specified dimension or a list of dimensions • Calculates first dimensions tagged as Accounts and as Time • Calculates dense dimensions before sparse • Syntax: CALC DIM(Accounts); (CALC DIM) Low Level data loaded Calculating Members Using Member Calc • Unary operators and equations • All database combinations for referenced member • Syntax: MemberName ; Exercise 3-2: Use Calc Functions Focusing Calculations • FIX…ENDFIX • IF…ELSE…ELSEIF…ENDIF • CROSS DIM OPERATOR -> Focusing Calculations Using Fix…Endfix • Isolates a portion of the database • Syntax: FIX FIX(mbrlist) commands; ENDFIX (East) Focusing Calculations Using Conditional Statements • • • • IF…ENDIF IF…ELSE…ENDIF IF…ELSEIF…ENDIF IF…ELSEIF…ELSE…ENDIF Focusing Calculations Using IF...ENDIF Performs conditional tests before performing a calculation Commission (IF(Sales > 200000) Commission = Sales * .012 ; ENDIF) IF condition is TRUE then do statement. IF condition is FALSE, then skip statement. Focusing Calculations Using ELSEIF…ELSE Performs conditional test if IF statement is FALSE Commission (IF(Sales >= 200000) Commission = Sales * .12; ELSEIF (Sales >= 100000) Commission = Sales * .098; ELSE Commission = Sales * .05; ENDIF) Focusing Calculations Using Cross Dim A pointer to data values of specific member combinations Syntax: -> Sales->Jan->Actual Exercise 3-3: Focus Calculations Generating Lists Using Macro Functions • Family Others • @CHILDREN • @UDA • @DESCENDANTS • @MATCH • @SIBLING • @RELATIVE • • Generation and level • @GENMBRS • @LEVMBRS Generating Lists Using @ICHILDREN Includes the specified member and all members in the level immediately below the specified member Given this outline FIX(@ICHILDREN(West)) … ENDFIX Applies calculations to the following: West, California, Oregon Generating Lists Using @IDESCENDANTS Includes the specified member and either all descendants or only the descendants down to a specified generation or level. Given the outline FIX(@IDESCENDANTS(WEST)) … ENDFIX returns the following: West,California,San Diego,San Francisco, Los Angeles, Chico, Oregon Generating Lists Using @UDA Generates a list of members that have the referenced UDA Given the outline, FIX(@UDA(MARKET,”Small Market”)) … ENDFIX applies calculations to the following: Connecticut, New Hampshire, and South Generating Lists Using @MATCH • Allows you to perform a wild-card search for members Given the following members 100-10 FIX(@MATCH(PRODUCT,”???-10”)) … ENDFIX 100-20 Returns the following: 100-10,200-10 200-10 200-30 300-20 Exercise 3-4: Using Macro Functions Testing for Values Using Boolean Functions • • • • @ISDESC @ISMBR @ISLEV Logical connectors Testing for Values Using @ISDESCENDANTS Tests member during calculation to determine appropriate formula for payroll Payroll (If (@ISDESC(East) OR @ISDESC (West)) Payroll = Sales * .15; ELSEIF (@ISDESC (Central)) Payroll = Sales * .11; ELSE Payroll = Sales * .10; ENDIF) Testing for Values Using @ISMBR Tests to see if a member is present for a specific calculation Fix (East) Commission ( If (@ISMBR(New York: New Hampshire)) Commission = Commission * 1.25 ; Endif ) Endfix Testing for Values Using @ISLEV Tests to see if a member is present for a specific calculation If the calculation is positioned on New York: @ISLEV(“Market”,0) is TRUE and @ISLEV(“Market”,1) is FALSE Using Logical Connectors with Boolean Functions • AND • OR • NOT Exercise 3-5: Using Boolean Functions Transforming Values with Math Functions • • • • @VAR @TRUNCATE @MIN @MOD • • • • @VARPER @ROUND @MAX @ABS Transforming Values with @VAR and @VARPER • • @VAR • @VARPER Calculates the variance (difference) between the values of two members • • Calculates the variance (difference) percent between the values of two members @VAR(Actual,Budget) • VARPER(Actual,Budget) Transforming Values with @TRUNCATE and @ROUND • • @TRUNCATE Removes the fractional part of an expression and returns the integer. Total_Sales = @TRUNCATE( @SUM(Direct_Sales: Other_Sales)); • • @ROUND Rounds an expression to the nearest whole number or to a specifically decimal Profit = @ROUND("Profit_%”); Transforming Values with @MIN and @MAX • @MIN • Returns the minimum value among the results of an expression Qtr1 = @MIN(Jan:Mar) ; • • @MAX Returns the maximum value among the results of an expression Qtr1 = @MAX(Jan:Mar) ; Transforming Values with @MOD • Calculates the modulus (the remainder) of a division operation Factor = @MOD("Margin %", "Profit %"); • “Margin %” = Dividend “Profit %” = Divisor Transforming Values with @ABS • @ABS returns the absolute value of an expression. Variance = @ABS(Actual-Budget) ; • The absolute value turns negative numbers into positive numbers: @ABS(-5) = 5 @ABS(+5) = 5 Exercise 3-6: Math Functions Test Your Understanding