Mondrian: OLAP power at your fingertips
Pentaho Analysis (aka Mondrian) is a powerful OLAP tool that can wrap just about any JDBC datasource and present it multidimensionally. There are many resources that cover how to get Mondrian connected to a database, some of the ins and outs of the the Mondrian.xml schema definition, etc. Comment below if you’re also interested in seeing a tutorial here in that regard.
Connecting from MDX to usefullness isn’t always the easiest… How powerful is MDX? Why would I do something in MDX versus SQL? Why not build another measure in my fact table to support that query instead of MDX? Well, I won’t belabor the benefits of MDX and the expressiveness of the language - there are plenty of great books and resources in that regard.
Suffice to say that it makes certain analytic queries (Year to Date, % contribution to total, this versus period prior) easy… sometimes embarrassingly easy compared to what we used to do in pure "star schema relational and SQL group by" land.
Let’s build a custom MDX measure and then in a followup I’ll show how provide this to your end users in Mondrian without this complexity.
- Download the latest pre configured installation (aka DEMO) of Pentaho here:
http://www.pentaho.org/download/latest.html - Unzip it into a directory on your local machine (we’ll refer to this as $PROOT from here on out).
- Double click on "$PROOT/pentaho-demo/start-pentaho.bat." When you see the message "Pentaho BI Platform Ready" the platform is ready, about 2 minutes.
- Open up firefox (or IE) and go to the following URL
http://localhost:8080, and then click on Samples and Examples
- Find Analysis examples, and click on that

and then click on
- You are now viewing the JPivot application that allows you to navigate and build OLAP reports in a web browser.

- (Optional Step) Feel free to explore the JPivot interface at your own leisure, a great place to start is the CUBE NAVIGATOR(
) which gives a pretty good graphical way of navigating OLAP cubes: Make changes, and then click on OK to make the crosstab report below change.
- Click on MDX to open up the MDX Editor Window

- Paste the following MDX into the text area and then hit APPLY:
select NON EMPTY {[Measures].[Actual]} ON COLUMNS,
NON EMPTY Hierarchize(Union({[Positions].[All Positions]}, [Positions].[All Positions].Children)) ON ROWS
from [Quadrant Analysis]You should see the report look like this:

- What we’re seeing here is the rollup of all of our head count (ie, salary expenditures) by position. The aggregate figure is nice, for the bean counters, but of interest to the analyst and executives is the "that is that in proportion to my entire enterprise?" In other words, 1,211,073.00 on HR Training personnel is not as interesting as what % I spend on HR Training personnel as part of the total. Let’s open paste the following calculated member into the MDX window ABOVE the current MDX statement:
with member [Measures].[Position Percent of Total] as ‘([Measures].[Actual] / ([Measures].[Actual], [Positions].CurrentMember.Parent))’, format_string = "|#.00%|"
Click APPLY and then Close the MDX editor (red X or the MDX button again).What we’ve done here is built a calculated measure that using MDX. MDX is very powerful so I suggest you check out some MDX books or resources on the net to explore its capabilities.
- Now we need to add our brand new calculated measure to our report. Click on the cube navigator, then "Measures" then highlight the new Measure we just created:

You have to click OK twice here to get back to the report. - If all has gone well, you should see the following report with your custom MDX measure:

Well, that’s great for the techies and hard core business analysts, but we’d never want to have to have an end user to have to figure all that out. How do we buffer the user from that complexity? That will be tomorrows blog entry on how to make a CalculatedMember in Mondrian.
Bonus Screenshot of a pie chart in two clicks now based on our percentage:



















