calc

March 3, 2018 | Author: shwetha17 | Category: Software, Technology, Computing, Mathematics, Computing And Information Technology
Share Embed Donate


Short Description

Download calc...

Description

ba se

Look Smarter Than You Are™ with Hyperion: Essbase Calc Scripts, Part 1 By Edward Roske, Oracle ACE Director, InterRel Consulting CEO

s Exploring Es

There’s a closely guarded secret to achieving great power in an Essbase block storage cube that can be summed up in one word: plastics. Wait, wrong movie; the secret for Essbase power is actually two words: calc scripts.

What’s a Calc Script?

A calc script (short for “calculation script”) allows you to override the standard Essbase outline calculations and take complete control of how your database derives its numbers. While most of the time calc scripts are run in batched intervals to do simple things like aggregate subsets of your database, they can also be launched sporadically by users such as during budgeting season to run allocation processes. Note that calc scripts can only be run against block storage cubes: the concept doesn’t exist in aggregate storage. If you want to do complex calculations like allocations in aggregate storage, run a calc script on a block storage cube and then pass the results (partitioning works well here) to an aggregate storage cube. While calc scripts may seem intimidating, they’re really sequential series of commands, equations, and formulas stored in normal text files (with the extension changed to .CSC to make them seem more mystical). They’re actually fairly easy to read (says the guy who’s been writing these things since the midnineties). To prove my point, here’s a calc script that will set all of your budget values to 50% above your actuals: /* Creates Initial Budget */ SET UPDATECALC OFF; CLEARDATA Budget; Budget = Actual * 1.5; CALC ALL; You might have noticed that this calc script actually does a few lines that go beyond just creating a budget, but we’ll get to those in due time. There are a lot of reasons to use a calc script. If you don’t want to calculate the entire database, a calc script can be written to only calculate the current month. If you want to clear data or copy data from one place to another, calc scripts can do the job. Want to create formulas that aren’t in the outline? Calc scripts are there for you. Calc scripts will even let you perform allocations and multi-pass calculations. When one of the endusers passes you a multi-stage allocation calculation that would make most Excel gurus run home crying to their parents (with whom they probably still live), you can just write an Essbase calc script to save the day.

Simplest Calc Script

While it may be small, size (in this case) doesn’t equate to power. This single line will aggregate all of the dimensional hierarchies in your outline, calculate all of the formulas attached

22 | First Quarter 2009 | ODTUG Technical Journal

to members, perform time balancing on time balanced members, and does it all quickly using “intelligent calculation.” This calc script is often referred to as the “default” calc script since if you don’t set anything else, this script is likely what will run: CALC ALL;

10 Rules for Calc Script Syntax

There are ten starter rules to follow when writing a calc script: 1. End every statement with a semicolon. 2. You do not talk about fight club. 3. You can break a statement onto multiple lines, but the end of the statement must have a semicolon. 4. If a member name contains spaces or starts with a number, surround it with “double quotes.” 5. Start comments with /* 6. End comments with */ 7. Statements must have a semicolon at the end. 8. Calc scripts are not case-sensitive. 9. Spaces between member names, commands, and functions don’t matter. 10. Don’t forget your semicolons (can’t mention that one enough). There are many more rules, but these are the important ones that people tend to forget and then wonder for hours why their calc scripts aren’t working. Here’s a calc script that demonstrates several of those syntax rules: /* Increase Opening Inventory */ “Opening Inventory” = “Opening InVeNtOrY” * 1.1; Notice that the first line is a comment and it has the appropriate start and end characters. “Opening Inventory” has a space in the member name, so it’s surrounded by double quotes. At the end of the entire statement (although not at the end of the comment), there’s a semicolon. (You can tell the calc script language was written by a programmer, because only programmers end sentences with semicolons;) Finally, observe that the second instance of Opening Inventory uses wacky cases just to show you that calc scripts are indeed not case-sensitive (unless you have explicitly told Essbase to behave otherwise).

Calculate Entire Dimensions

The most common use for a calc script is to aggregate a dimension. You’ve already seen the simple command that tells Essbase to evaluate all your member formulas and do all of your outline aggregation. While “CALC ALL” is great and powerful, there are times when you only want to calculate specific

CALC DIM (Product); This line calculates the Product dimension doing both outline aggregation (such as rolling all the Colas up into the parent value) and member formulas, if they exist for members in that dimension. If we want to calculate multiple dimensions using this command (say, Market and Product), just separate them with commas: CALC DIM (Market, Product); Remember how we said that “CALC DIM” not only does aggregation but also member formulas? Well, how many member formulas are there in the Market and Product dimensions? That’s right: none, so “CALC DIM” is wasting time looking for formulas that you know aren’t there. For sparse dimensions that don’t have formulas, there’s a command that only does aggregation and as such, is usually faster: AGG (Market, Product);

Calculate a Subset of Data

While calculating entire dimensions makes you feel very powerful, sometimes you just want to calculate a portion of the database. For instance, let’s say you just updated your budgets but you didn’t touch actuals. How could you ignore the Actual member? Well it turns out that there’s an optional argument to the “CALC ALL” command called “EXCEPT”. You use it to calculate everything except specific dimensions (DIM) or members (MBR). If we didn’t want to calculate actuals, we’d say: CALC ALL EXCEPT MBR (Actual); It’s also possible to list multiple members. Say that we didn’t want to calculate the great state of Texas and the probably also great state of New York. We’d list the members separated by commas: CALC ALL EXCEPT MBR (Texas, “New York”); If there’s an entire dimension you don’t want to calculate, replace “MBR” with “DIM”: CALC ALL EXCEPT DIM (Measures);

sister command “ENDFIX”. If we just want to calculate Cola and Florida we put these after the “FIX” separated by commas: FIX (Cola, Florida) CALC DIM (Measures); ENDFIX “FIX” and “ENDFIX” are called sandwich commands because one command is like the top layer of bread and the other as the bottom with lots of things thrown in between.

Where to Next?

In the next quarter’s installment of this article, we will cover clearing data, copying data, conditional operators, and a couple of key functions. If you can’t wait three whole months for more information, some of the material above was previously published in the book Look Smarter than You Are with Essbase System 9 and there’s further material there too. While my book costs money (search for Essbase on lulu.com if you’re interested), you can also get free calc script information from the Essbase Database Administrator’s Guide which can be found on Oracle.com. To stay in touch with up-to-date news in the world of Oracle EPM (or Hyperion or Essbase or whatever the name of the week is), visit my Hyperion blog at http://looksmarter.blogspot. com/. I’ll see you next quarter as I continue to help you look smarter than you are with Essbase Calc Scripts.

About The Author

ber Mem

Edward Roske, Oracle ACE Director, is the co-author of the best-selling Hyperion book Look Smarter than You are with Essbase. He is CEO of interRel Consulting, a Hyperion-specific consulting firm, and blogs about Hyperion matters at looksmarter.blogspot.com. He was co-chair of the Hyperion track at ODTUG Kaleidoscope 2008 and is currently the president of ODTUG’s Hyperion Developer’s SIG. Edward is an unfathomably frequent speaker at Oracle/Hyperion conferences and he is noted for his humorous slant to unbelievably boring information. He spends his spare time evolving into pure energy and saving busloads of nuns & orphans. He also likes puppies.

While this method may be fun at first, it’s not nearly the most powerful method for limiting a calculation to a small portion of the database. Let’s say we just loaded our budgets for next year for the Cola in Florida. Now we just want to calculate our Measures dimension for that one member, ignoring the rest of the database. The “CALC ALL EXCEPT…” method from above is really used to do the majority of a database and not just a smidgen, so we need a new command: “FIX” and its

First Quarter 2009 | ODTUG Technical Journal | 23

Look Smarter Than You Are™ . . . (Continued)

dimensions. For instance, what would we do if we just wanted to calculate Sample.Basic’s Product dimension? We have a new command for this called “CALC DIM” (short for calculate dimension):

View more...

Comments

Copyright ©2017 KUPDF Inc.
SUPPORT KUPDF