Book Image

Oracle Essbase 11 Development Cookbook

By : Jose R Ruiz
Book Image

Oracle Essbase 11 Development Cookbook

By: Jose R Ruiz

Overview of this book

Oracle Essbase is a Multi-Dimensional Online Analytical Processing (OLAP) server, providing a rich environment for effectively developing custom analytic and enterprise performance management applications. Oracle Essbase enables business users to quickly model complex business scenarios. This practical cookbook shows you the advanced development techniques when building Essbase Applications and how to take these applications further. Packed with over 90 task-based and immediately reusable recipes, this book starts by showing you how to use a relational data model to build and load an Essbase cube and how to create a data source, prepare the mini schema, and work with the data elements in Essbase Studio. The book then dives into topics such as building the BSO cube, building the ASO cube, using EAS for development, creating Calculation Scripts and using MaxL to automate processes.
Table of Contents (17 chapters)
Oracle Essbase 11 Development Cookbook
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Adding and populating the Sort Order Column


In previous releases of Essbase, a developer had the option of building a hierarchy in ascending or descending alphabetical order via a build rule. If you wanted to sort the hierarchies in a different order, then you would go into Essbase Administrative Services (EAS). Then, open the outline, and drag and drop the members in the order that the business wanted or extract the dimension using an Outline Extract utility, sort the hierarchy, and use a build rule to rebuild the dimension. In contrast, when we are using Essbase Studio, in version 11.1.2.1, we are going to have to define the Sort Order in the relational environment. If you have the Oracle's data-governance software Data Relationship Management (DRM), this task will be handled there, but this recipe shows you how to load the Sort Order field with some SQL knowledge and Excel.

Getting ready

To get started, open SQL Server Management Studio, and add a database called TBC, if you have not already done it. In this recipe, we are using T-SQL and providing the PL\SQL equivalent where the syntax is different. You need to add a SCHEMA instead and use a tool like TOAD or Golden, if you are using Oracle. You should also open an Excel workbook.

How to do it...

  1. Execute the following query to create the YEARS table. We can change the script below to PL/SQL by replacing int with INTEGER and varchar() with VARCHAR2():

    --For T-SQL user
    Create Table YEARS(
      YEARID       int         NOT NULL,
      YEAR         int         NULL,
      QUARTER      varchar(80)     NULL,
      MONTH        varchar(80)     NULL,
      MONTH_ALIAS  varchar(80)     NULL,
      Constraint PK_YEAR_YEARID Primary Key(YEARID Asc)
    ); 
  2. Execute the following script to add the SORT_ORDER column:

    --This is the syntax in T-SQL
    Alter Table YEARS Add SORT_ORDER INT NULL;
    --This is the syntax in PL/SQL
    Alter Table YEARS Add SORT_ORDER INTEGER NULL;
  3. Open Excel and enter the YEARS dimension's data starting with field A1, as follows:

  4. Sort the hierarchy manually, if it does not look right in the order specified in the preceding screenshot. Enter the number 1 in cell F1 and formula =F1+1 in cell F2.

  5. Click on cell F2, then click on the box to the right and bottom of the cell, and drag it down to cell F12.

  6. Enter the following concatenation string in cell G1, select G1, and press CTRL+C. Select range G2:G12, and press CTRL+V to paste the concatenation string:

    ="Insert Into TIME Values (" & A1 & ", " & B1 & ", '"& C1 & "', '" & D1 & "', '" & E1 & "', '" & F1 & "');"
  7. Copy range G1:G12, open up SQL Management Studio, connect to the TBC database, paste the range in the query window, and execute the following queries:

    Insert Into YEARS Values(1, 2011, 'QTR1 11', 'Jan 2011', 'January 2011', '1');
    Insert Into YEARS Values(2, 2011, 'QTR1 11', 'Feb 2011', 'February 2011', '2');
    Insert Into YEARS Values(3, 2011, 'QTR1 11', 'Mar 2011', 'March 2011', '3');
    Insert Into YEARS Values(4, 2011, 'QTR2 11', 'Apr 2011', 'April 2011', '4');
    Insert Into YEARS Values(5, 2011, 'QTR2 11', 'May 2011', 'May 2011', '5');
    Insert Into YEARS Values(6, 2011, 'QTR2 11', 'Jun 2011', 'June 2011', '6');Insert Into YEARS Values(7, 2011, 'QTR3 11', 'Jul 2011', 'July 2011', '7');
    Insert Into YEARS Values(8, 2011, 'QTR3 11', 'Aug 2011', 'August 2011', '8');
    Insert Into YEARS Values(9, 2011, 'QTR3 11', 'Sep 2011', 'September 2011', '9');
    Insert Into YEARS Values(10, 2011, 'QTR4 11', 'Oct 2011', 'October 2011', '10');
    Insert Into YEARS Values(11, 2011, 'QTR4 11', 'Nov 2011', 'November 2011', '11');
    Insert Into YEARS Values(12, 2011, 'QTR4 11', 'Dec 2011', 'December 2011', '12'); 
    

How it works...

The following are the steps in this recipe:

  1. We added the YEARS table to the TBC database.

  2. We added the SORT_ORDER column to the YEARS table.

  3. We added an integer used to sort the members.

  4. We also entered the YEARS dimension into an Excel sheet and sorted our YEARS hierarchy.

  5. After placing the SORT_ORDER into column F1, we pasted the correct SORT_ORDER and concatenate Insert statements together with the values in Excel.

  6. Finally, we used the Insert statements in the Excel workbook to update the YEARS table using the SQL Management Studio.

The following is what your YEARS hierarchy should look like without the SORT_ORDER column:

2011

  
 

QTR1 11

 
  

Feb 2011

  

Jan 2011

  

Mar 2011

 

QTR2 11

 
  

Apr 2011

  

Jun 2011

  

May 2011

 

QTR3 11

 
  

Aug 2011

  

Jul 2011

  

Sep 2011

 

QTR4 11

 
  

Dec 2011

  

Nov 2011

  

Oct 2011

Essbase Studio will enter February into the outline before January, May will be after June, August will be before July, and the fourth quarter will be completely out of order. For this reason, it is suggested that you add a SORT_ORDER column to all of your dimension tables.

See also

Refer to the Using Sort Order on data elements recipe in Chapter 2 to learn how to set the sort order for your metadata elements.