Essbase Calc Script

You might also like

You are on page 1of 3

http://www.obs3.com/ess_tips.shtml When do I use "IF" and "FIX" in calculation scripts?

In general, you should try and only use "FIX" statements on SPARSE dimensions. FIX statements allow you to take a slice of the database and only perform an action on that slice. If you fix on a SPARSE dimension, then you are limiting the amount of blocks that you are performing the action upon. If you FIX on a DENSE dimension, you are not limiting the number of blocks, but rather just a portion within each block. Using the FIX statement on a dense dimension can cause multiple passes through the same blocks which is very inefficient. On the other hand, the IF statement is well suited to DENSE dimensions because it performs IF logic while the block is in memory. Example: If JUL then ..., else .... will all be performed in one pass without the need of multiple passes through the blocks. In general, try and use FIX on sparse dimensions and IF on dense dimensions. How do I dynamically update my forecast scenario with Actual?

Most companies have a "forecast" scenario which is a combination of actuals and forecast. All prior months contain actual data and all future months contain the remaining forecast. An easy way to update the forecast dimension with actuals each month is to use Essbase substitution variables. Set up two substitution variables in Essbase: One called CURR_MONTH and one called NEXT_MONTH. The current month variable should contain the name of the month that has the most current month of actuals. Load the new Actuals into the "Actuals" dimension. Then run a calc script similar to the one shown below to copy the actual values into the forecast scenario. FIX(JAN:&CURR_MONTH) Cleardata Forecast; DATACOPY "Actuals" to Forecast; ENDFIX This calculation script will clear the forecast data from JAN through the current month, and then copy the actuals scenario to the forecast scenario for those months. In all of the calculation scripts that pertain to the "Forecast" scenario you can use the NEXT_MONTH variable to only calculate the future months. FIX(&NEXT_MONTH:DEC) ................................ ENDFIX

How can I use the @MDSHIFT function?

The @MDSHIFT function is a very powerful function that allows you to write Essbase functions without have to "hard code" the member names into the calculation scripts. Here is a classic example of where the @MDSHIFT function can be used: Cube contains the following dimensions: Accounts, Business Units, Scenario, Time, and Years There is a balance sheet account called "Inventory" which for the current year, goes back to the previous year forecast scenario for it's beginning balance. You could write the calc script as follows: FIX(@GENMBRS("Time",4),"Plan", &YEAR1) "Inventory" ( If(@ISMBR(JAN)) "Inventory" = "Inventory"->FY03->DEC->Forecast) + "New Inventory" ; ELSE "Inventory" = @PRIOR("Inventory",1) +"New Inventory"; ENDIF ) ENDFIX; This works fine, but each year you would have to edit the year within the calculation script. (FY03) Instead of hard coding the script you can use the @MDSHIFT function to dynamically grab the value.

FIX(@GENMBRS("Time",4),"Plan", &YEAR1) "Inventory" ( If(@ISMBR(JAN)) "Inventory" = @MDSHIFT("Inventory",-1,Years,,11,"Time",,-1,Scenarios,) + "New Inventory" ; ELSE "Inventory" = @PRIOR("Inventory",1) +"New Inventory"; ENDIF ) ENDFIX; The @MDSHIFT function goes back one year, goes down 11 members in the Time dimension, and then goes up one member on the scenario dimension. In the above example the "Plan" member is listed just below the "Forecast" member on the scenario dimension.

How can I create a global "Prior Period Chg" calculation? In order to create a 'global' prior period chg calculation, you should first create an additional dimension which can be used for global calculations. If you already have a metrics type dimension, you can use this formula to calculate the prior period chg for any intersection in the cube. This example displays the formula for a cube which has a separate Time and Years dimension. IF(@ISGEN("Time",4)) If(@ISMBR(JAN)) Amount - @MDSHIFT("Amount",-1,Years,,11,"Time",); ELSE Amount - @PRIOR("Amount",1); ENDIF; ELSEIF (@ISGEN("Time",3)) If(@ISMBR(Q1)) Amount- @MDSHIFT("Amount",-1,Years,,3,"Time",(Q1,Q2,Q3,Q4)); ELSE Amount -@PRIOR("Amount",1,Q1:Q4); ENDIF; ELSE Amount - @MDSHIFT("Amount",-1,Years,); ENDIF; What causes database fragmentation? Essbase database fragmentation occurs when blocks are "re-written" within the database. Not all "re-writes" to a cube will cause fragmentation. Listed below are some behaviors that can cause Essbase fragmentation.

Sending data to a dense dimension that previously did not have any data - This occurs when you have a write back cube where users are adding new data to a dense dimension, such as adding data to the current month or adding data to an account that previously did not have any data. (Assuming that time and accounts are dense) Loading data into a cube - Load rules can also cause database fragmentation if they are not set up properly. When loading data into Essbase, you always want to sort the data so that sparse dimensions are represented first in the data loads. The sorting of data files/sources has a huge impact on Essbase performance and fragmentation. Rule of thumb: make sure that the data source is sorted by the columns that represent the sparse dimensions first. Adding incremental data to a cube - Adding the "current month's data" to an Essbase cube can cause fragmentation if the time dimension is tagged as dense.

Fragmentation has a huge impact on cube performance. There are two ways to "un-fragment" an Essbase cube. One is to clear and reload the data into the cube. The other is to cause Essbase to perform a dense restructure.

How can I easily create global calculations? The power of OLAP cubes and Essbase is truly realized with ease of creating calculations. OLAP cubes were created for in depth analysis and speedy queries. The easiest way to create 'global' calculations in Essbase is to create a new dimension which contains all of the global calculations.

Example: A company has a cube which calculates product revenue. The cube contains 20 separate measures ranging from revenue dollars to inventory. Let us assume that the company has a metric called "Per Case" that they would like applied to each of the 20 measures. One approach would be to create a new calculation for each measure. (Inventory per case, Revenue per case, etc.) Although this approach does work, it is pretty maintenance intensive. A better approach might be to create a new dimension called "Metrics". The metrics dimension would contain one stored member called "Amount". All data in ethe cube would be tied to this one member on the Metrics dimension. With the addition of the new dimension, it is now very easy to create a new 'global' calculation called "Per Case". The formula would be as follows: Amount / Amount -> Cases; You can tag the member as "dynamic calc" and "two pass" and you will have a global calculation which calculates the "per case" amount for all of the accounts. My right mouse pop up menu no longer works in Excel? When the Essbase/Excel add-in is installed, the default behavior is for Essbase to "take over" your right mouse click. This is because the Excel add-in provides for some additional Essbase functionality. (The problem is that it is installed without your knowledge) To regain control of your right mouse pop up menu in Excel:

Go to the Essbase menu and choose Options.... Click on the global tab Uncheck the "enable secondary button" under the "mouse actions" section.

Excel treats my account member names as numeric so Essbase doesn't recognize. This is a common problem with Essbase cubes when interacting with Excel. Oftentimes, financial cubes contain account numbers or cost center numbers within the cubes. When these numbers are entered into Excel, Excel automatically assumes that these names are numbers. When Excel treats the names as numeric, Essbase can not interpret the values as names. An easy way to fix this problem is with the use of some simple VBA code in Excel. This code will insert an apostrophe into all of the selected cells within Excel. You can attach this code to an Excel menu for easy access by users. Sub Insert_Apostrophes() Dim cell As range Dim rng As range On Error GoTo HandleErr Set rng = selection For Each cell In rng cell.Value = "'" & cell.Value Next cell ExitHere: Exit Sub HandleErr: Select Case err.Number Case Else MsgBox "Error " & err.Number & ": " & err.Description, vbCritical, "Procedures.Insert_Apostrophes" 'ErrorHandler:$ $N=Procedures.Insert_Apostrophes End Select End Sub

You might also like