Documenti di Didattica
Documenti di Professioni
Documenti di Cultura
Data
OLAP Cubes provide a convenient way to crunch data in Excel. Imagine a Pivot Table pulling information
from thousands or millions of data points with hundreds of columns and you being able to share this
humongous data set with colleagues using an Excel spreadsheet that weights nothing more than a few
Kilobytes. Add to this the ability to update the source data while the users get to look at that information
real time. Thats what a Pivot Table based on an OLAP cube can do for you. A disclaimer : You will not be
able to create an OLAP cube in Excel 2007 the functionality has been deprecated. To create an OLAP
cube you will have to rely on good ol Excel 2003 though you can create a pivot table in Excel 2007 with an
OLAP cube as the source.
Provide a name to the data source and select the type of driver that you want to use for the purpose. In our
case, since we are using a .txt file as the raw data, we will use the Microsoft Text Driver. Press Ok.
Uncheck the Use Current Directory checkbox and select the directory where the raw data file has been
placed.
Three clicks on the Ok button bring you back and opens up the Query Wizard.
The left hand box has a list of the data sources in the directory that we selected in the previous step. You
can use more than one data source at a time, though in our case, we will be sticking to just one. Move all
the items (or the ones that you like) to the box on the right and press next. You can provide filtering and
sorting options in the next two forms but we will just give them a miss for now and simply click Next which
brings us to the final screen.
Heres where the difference between Excel 2003 and Excel 2007 lie in terms of creating OLAP cubes.
While in Excel 2003, you will see three options (shown below), in Excel 2007 you only be presented with
two options with the option to Create an OLAP cube from this query having been taken away.
Fortunately for us, we still have access to Excel 2003 and we choose the third option the one to create
the OLAP cube. On pressing Ok, the OLAP Cube wizard opens up.
Press ok and move onto the next step where we specify the field that we would like to summarize. Think of
this as the data field in a pivot table. In our case, it is sales since we would like to analyze sales across
product, regions and date ranges.
Press Next. Specify the fields that we would like to use to make the OLAP cube. Choose only the ones
that you are sure that you would like to use choosing everything, especially if you have a large number of
fields, can slow down the cubes response time.
Press Next where we provide the location where we can store the cube.
Press Ok and the application will provide a new form asking for the path where to store the OLAP query .
The moment you press ok, the OLAP cube creation process begins and may take a few seconds. This is
the points where Excel pack the cube with information from the raw data file. The moment the process is
complete, the application would open up the familiar Pivot Table Creation Wizard form. At this point, if the
sole purpose was to make an OLAP cube, we can cancel (press esc key). If you would like to proceed, you
can use specify the pivot table layout and save the file. In our case, since we wanted Excel to create the
cube for us, we click Cancel. Lets move over to Excel 2007 to see how we can use this cube to create a
Pivot Table. If we go back to the specified directory, we will see a new file with a .cub extension having
been created by Excel. Thats the cube !
Choose to Use an external data source and then use the Browse for more button to locate the .cub file
that we created in the previous step.
The form picks up the OLAP cube as the data source and shows the connection name.
Press ok and viola ! We are presented with a Pivot Table thats based out of the OLAP Cube.
1 Using VBA
2 Sub check_OLAP()
3 Dim pvt As PivotTable
4 Set pvt = ActiveSheet.PivotTables(1)
5 MsgBox "Pivot Table uses OLAP Cube " & pvt.PivotCache.OLAP
6 End Sub