{"id":177,"date":"2006-06-08T16:31:29","date_gmt":"2006-06-08T23:31:29","guid":{"rendered":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/2006\/06\/08\/mondrian-power-of-olapmdx-at-your-fingertips\/"},"modified":"2006-06-08T16:31:29","modified_gmt":"2006-06-08T23:31:29","slug":"mondrian-power-of-olapmdx-at-your-fingertips","status":"publish","type":"post","link":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/2006\/06\/08\/mondrian-power-of-olapmdx-at-your-fingertips\/","title":{"rendered":"Mondrian: OLAP power at your fingertips"},"content":{"rendered":"<p>Pentaho Analysis (aka Mondrian) is a powerful OLAP tool that can wrap just about any JDBC datasource and present it multidimensionally.\u00a0 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.\u00a0 Comment below if you&#8217;re also interested in seeing a tutorial here in that regard.<\/p>\n<p>Connecting from MDX to usefullness isn&#8217;t always the easiest&#8230; How powerful is MDX?\u00a0 Why would I do something in MDX versus SQL?\u00a0 Why not build another measure in my fact table to support that query instead of MDX?\u00a0 Well, I won&#8217;t belabor the benefits of MDX and the expressiveness of the language &#8211; there are plenty of great books and resources in that regard.<\/p>\n<p>Suffice to say that it makes certain analytic queries (Year to Date, % contribution to total, this versus period prior) easy&#8230; sometimes embarrassingly easy compared to what we used to do in pure &quot;star schema relational and SQL group by&quot; land.<\/p>\n<p>Let&#8217;s build a custom MDX measure and then in a followup I&#8217;ll show how provide this to your end users in Mondrian without this complexity.<\/p>\n<ol>\n<li>Download the latest pre configured installation (aka DEMO) of Pentaho here:<br \/><a href=\"http:\/\/www.pentaho.org\/download\/latest.html\">http:\/\/www.pentaho.org\/download\/latest.html<\/a><\/li>\n<li>Unzip it into a directory on your local machine (we&#8217;ll refer to this as $PROOT from here on out).<\/li>\n<li>Double click on &quot;$PROOT\/pentaho-demo\/start-pentaho.bat.&quot;\u00a0 When you see the message &quot;Pentaho BI Platform Ready&quot; the platform is ready, about 2 minutes.<\/li>\n<li>Open up firefox (or IE) and go to the following URL<br \/>http:\/\/localhost:8080, and then click on Samples and Examples<br \/><img decoding=\"async\" loading=\"lazy\" height=\"508\" style=\"margin:5px;\" width=\"450\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2016-%2050-%2048.png\" \/><\/li>\n<li>Find Analysis examples, and click on that<br \/><img decoding=\"async\" loading=\"lazy\" height=\"108\" style=\"margin:5px;\" width=\"301\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2016-%2053-%2032.png\" \/><br \/>and then click on <br \/><img decoding=\"async\" loading=\"lazy\" height=\"194\" style=\"margin:5px;\" width=\"299\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2016-%2054-%2047.png\" \/><\/li>\n<li>You are now viewing the JPivot application that allows you to navigate and build OLAP reports in a web browser.<br \/><img decoding=\"async\" loading=\"lazy\" height=\"79\" style=\"margin:5px;\" width=\"450\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2016-%2057-%2005.png\" \/><\/li>\n<li><strong>(Optional Step) <\/strong>Feel free to explore the JPivot interface at your own leisure, a great place to start is the CUBE NAVIGATOR(<img decoding=\"async\" loading=\"lazy\" height=\"23\" style=\"margin:5px;\" width=\"25\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2016-%2058-%2038.png\" \/>) which gives a pretty good graphical way of navigating OLAP cubes:\u00a0 Make changes, and then click on OK to make the crosstab report below change.<br \/><img decoding=\"async\" loading=\"lazy\" height=\"200\" style=\"margin:5px;\" width=\"187\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2000-%2037.png\" \/><\/li>\n<li>Click on MDX to open up the MDX Editor Window<br \/><img decoding=\"async\" loading=\"lazy\" height=\"216\" style=\"margin:5px;\" width=\"330\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2003-%2020.png\" \/><\/li>\n<li>Paste the following MDX into the text area and then hit APPLY:\n<p><strong>select NON EMPTY {[Measures].[Actual]} ON COLUMNS,<br \/> NON EMPTY Hierarchize(Union({[Positions].[All Positions]}, [Positions].[All Positions].Children)) ON ROWS<br \/>from [Quadrant Analysis]<\/strong><\/p>\n<p>You should see the report look like this:<br \/><img decoding=\"async\" loading=\"lazy\" height=\"491\" style=\"margin:5px;\" width=\"357\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2006-%2055.png\" \/><\/li>\n<li>What we&#8217;re seeing here is the rollup of all of our head count (ie, salary expenditures) by position.\u00a0 The aggregate figure is nice, for the bean counters, but of interest to the analyst and executives is the &quot;that is that in proportion to my entire enterprise?&quot;\u00a0 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.\u00a0 Let&#8217;s open paste the following calculated member into the MDX window ABOVE the current MDX statement:<br \/><strong>with member [Measures].[Position Percent of Total] as &#8216;([Measures].[Actual] \/ ([Measures].[Actual], [Positions].CurrentMember.Parent))&#8217;, format_string = &quot;|#.00%|&quot;<br \/><\/strong><img decoding=\"async\" loading=\"lazy\" height=\"190\" style=\"margin:5px;\" width=\"765\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2012-%2049.png\" \/><br \/>Click APPLY and then Close the MDX editor (red X or the MDX button again).\n<p>What we&#8217;ve done here is built a calculated measure that using MDX.\u00a0 MDX is very powerful so I suggest you check out some MDX books or resources on the net to explore its capabilities.<\/li>\n<li>Now we need to add our brand new calculated measure to our report.\u00a0 Click on the cube navigator, then &quot;Measures&quot; then highlight the new Measure we just created:<br \/><img decoding=\"async\" loading=\"lazy\" height=\"206\" style=\"margin:5px;\" width=\"288\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2017-%2026.png\" \/><br \/>You have to click OK twice here to get back to the report.<\/li>\n<li>If all has gone well, you should see the following report with your custom MDX measure:<br \/><img decoding=\"async\" loading=\"lazy\" height=\"684\" style=\"margin:5px;\" width=\"552\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2019-%2043.png\" \/><\/li>\n<\/ol>\n<p>Well, that&#8217;s great for the techies and hard core business analysts, but we&#8217;d never want to have to have an end user to have to figure all that out.\u00a0 How do we buffer the user from that complexity?\u00a0 That will be tomorrows blog entry on how to make a CalculatedMember in Mondrian.\u00a0 <\/p>\n<p>Bonus Screenshot of a pie chart in two clicks now based on our percentage:<br \/><img decoding=\"async\" loading=\"lazy\" height=\"526\" style=\"margin:5px;\" width=\"620\" alt=\"\" src=\"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-content\/uploads\/2006\/06\/blog-%202006-%2008-%2017-%2025-%2011.png\" \/><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Pentaho Analysis (aka Mondrian) is a powerful OLAP tool that can wrap just about any JDBC datasource and present it multidimensionally.\u00a0 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.\u00a0 Comment below if you&#8217;re also interested in [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[16],"tags":[],"_links":{"self":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/posts\/177"}],"collection":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/comments?post=177"}],"version-history":[{"count":0,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/posts\/177\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/media?parent=177"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/categories?post=177"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.nicholasgoodman.com\/bt\/blog\/wp-json\/wp\/v2\/tags?post=177"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}