The rather-too-many ways to crossjoin in MDX

0

Posted on : 06-07-2011 | By : Ben Stinner | In : Analytics

In my last post I made the point that it’s a bit too easy to write and MDX query that works, even if you don’t really understand why it works, and in this post I’m going to address a similar issue. In MDX one of the commonest set operations is a crossjoin, and while most people understand what this operation does there are so many ways of writing a crossjoin in MDX that it can hurt readability and make the language even more confusing for newcomers. So what are all these different ways of crossjoining, and which one is to be preferred?

First of all, let’s look at what a crossjoin actually does. Imagine we have two sets, each with two members in them: {A,B} and {X,Y}. If we crossjoin these two sets together, we get a set of tuples containing every possible combination of A and B and X and Y, ie the set {(A,X), (A,Y), (B,X), (B,Y)}.

As an example of this, let’s look at the first way of doing a crossjoin in MDX: the Crossjoin() function. Here’s a query against the Adventure Works cube that returns the crossjoin of the two sets {Married, Single} and {Female, Male} on the rows axis:

SELECT {[Measures].[Internet Sales Amount]} ON 0,
CROSSJOIN(
{[Customer].[Marital Status].[M], [Customer].[Marital Status].[S]}
,
{[Customer].[Gender].[F],[Customer].[Gender].[M]}
)
ON 1
FROM [Adventure Works]

Here’s the output:

77854 image thumb The rather too many ways to crossjoin in MDX

As you’d expect, you get four rows for each of the four tuples in the set: {(Married, Female), (Married, Male), (Single, Female), (Single, Male)}.

What are the pros and cons of using the Crossjoin() function then? Well, one thing it’s worth stating is that all of the different ways of doing crossjoins in MDX perform just as well as the others, so it’s purely a question of readability and maintainability. On those criteria its main advantage is that it’s very clear you’re doing a crossjoin – after all, that’s the name of the function! However, because it carries an overhead in terms of the numbers of brackets and commas and the name of the function itself, which isn’t so good for readability, and this is why I generally don’t use it. When you’re crossjoining a lot of sets together, for example:

SELECT {[Measures].[Internet Sales Amount]} ON 0,
CROSSJOIN(
{[Customer].[Marital Status].[M], [Customer].[Marital Status].[S]}
,
{[Customer].[Gender].[F],[Customer].[Gender].[M]}
,
[Customer].[Education].[Education].MEMBERS
,
[Customer].[Total Children].[Total Children].MEMBERS
)
ON 1
FROM [Adventure Works]

…you might need to look a long way up to the top of the query to find out you’re doing a crossjoin.

The most popular alternative to the Crossjoin() function is the * operator. This allows you to crossjoin several sets by simply putting an asterisk between them, for example:

SELECT {[Measures].[Internet Sales Amount]} ON 0,
{[Customer].[Marital Status].[M], [Customer].[Marital Status].[S]}
*
{[Customer].[Gender].[F],[Customer].[Gender].[M]}
ON 1
FROM [Adventure Works]

It’s more concise than the Crossjoin() function and I think easier to read; it also has the advantage of being the most frequently-used syntax. However there are rare cases when it can be ambiguous because an asterisk is of course also used for multiplication. Consider the following calculated measure in the following query:

WITH
MEMBER MEASURES.DEMO AS
([Measures].[Internet Sales Amount]) * ([Customer].[Gender].[F])
SELECT {[Measures].DEMO} ON 0,
{[Customer].[Marital Status].[M], [Customer].[Marital Status].[S]}
ON 1
FROM [Adventure Works]

Are we crossjoining or multiplying here? Actually, we’re multiplying the result of the two tuples together, rather than returning the result of the tuple ([Measures].[Internet Sales Amount], [Customer].[Gender].[F]), but it’s not easy to tell.

The third way of doing a crossjoin is one I particularly dislike, and it’s the use of brackets and commas on their own as follows:

SELECT {[Measures].[Internet Sales Amount]} ON 0,
({[Customer].[Marital Status].[M], [Customer].[Marital Status].[S]}
,
{[Customer].[Gender].[F],[Customer].[Gender].[M]})
ON 1
FROM [Adventure Works]

This is for me the least readable and most ambiguous syntax: in my mind round brackets denote a tuple and here we’re getting a set of tuples. I’d therefore advise you not to use this syntax.

Last of all, for maximum MDX geek points, is the Nest() function. Almost completely undocumented and unused, a hangover from the very earliest days of MDX, it works in exactly the same way as the Crossjoin() function:

SELECT {[Measures].[Internet Sales Amount]} ON 0,
NEST(
{[Customer].[Marital Status].[M], [Customer].[Marital Status].[S]}
,
{[Customer].[Gender].[F],[Customer].[Gender].[M]}
)
ON 1
FROM [Adventure Works]

Of course you’d never want to use it unless you were either showing off or wanted to confuse your colleagues as much as possible…

In summary, I’d recommend using the * operator since it’s probably the clearest syntax and also the most widely-accepted. Equally importantly, I’d advise you to be consistent: choose one syntax, stick with it and make sure everyone on the project does the same.

Article source: http://feedproxy.google.com/~r/wordpress/Cpjz/~3/YE_I7p1O_Lk/

  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX
  • wp socializer sprite mask 16px The rather too many ways to crossjoin in MDX

Data Blooms in Beauty and Truth

1

Posted on : 06-07-2011 | By : Ben Stinner | In : Analytics

Two of my recent blog posts critiqued the data visualizations of David McCandless and found them wanting. In those posts I repeated an argument that I’ve been making for some time now: quantitative data can be displayed in ways that are both beautiful (to produce “awe”) and functional (to produce “ah-ha”), without compromising either. In situations when the attention of people must first be captured before their minds can be informed, this can and should be done in a way that maintains the integrity of the information. The attention-getting component of the story need not be the chart that presents the data, but something complementary, such as a photo, diagram, or some other image—perhaps even words—that appeal to the eye or heart. If a quantitative chart is used to grab attention, it can serve a limited communication function as an introduction to the story or overview of the data, and serve as a launch-pad to other charts that are richer in information. I’d like to illustrate this with a beautiful example.

On the website of the Organisation for Economic Co-operation and Development (OECD) you can explore how the 34 member countries compare to one another across 11 measures that contribute to the quality of life using an interactive infographic called the Better Life Index. Here’s what you see upon arrival:

24e26 better life index overview small Data Blooms in Beauty and Truth
Click to view the full-sized interactive version.

Be sure to view the larger interactive version of this chart to appreciate its elegance and explore its story. It is immediately engaging aesthetically and informatively. The flowers, one for each country, form glyphs: graphical objects that represent multiple data variables. Each petal represents a different quality-of-life measure: the longer the petal the higher the value. Glyphs don’t provide a way to compare the better life profiles of these countries precisely (we’ll get to that later), but they provide an informative overview. It is easy to spot the country that has the shortest petals overall: Turkey. It is easy to find countries that primarily have long petals and thus high values across all measures of a better life. It is easy to spot countries with a significant imbalance of some long and some short petals, such as Spain. Details such as the fact that Austria rates much lower in one area compared to others are also easy to spot. A great deal of information can be gleaned from this overview.

If it stood alone, the ability of this infographic to inform would be limited in a way that I would find annoying, but it doesn’t stand alone. What is that one value in Austria that is much lower than the rest? With some effort we could figure it out from the color legend, but a better way is readily available. While hovering over Austria with my mouse, the following view pops up:

f5ac9 better life index bars Data Blooms in Beauty and Truth

That smaller value is “Income.” With this simple horizontal bar graph, which is readily available in the moment that we need it, we can compare each measure of life in Austria with greater ease and precision by relying on visual perception’s exceptional ability to compare the lengths of objects that share a common baseline. The initial flower chart does not attempt to tell all parts of the story. In fact, each aspect of the story that comes to mind as potentially interesting is supported by a different visualization that is designed to present it clearly and accurately.

As a citizen of the United States, I was interested in seeing how our quality of life here compares to other OECD countries. By clicking on the flower that represents the United States, I was able to view this information as follows:

e573f better life index country detail small Data Blooms in Beauty and Truth
Click to enlarge.

On the left, words are used to provide the narrative, while on the right a visual display makes it easy to see how the United States compares to the other countries at a glance. The series of small vertical bars next to each label (Housing, Income, etc.) represents in miniature the values associated with each country ranked from lowest to highest, with the highlighted bar representing the United States. These tiny graphs tell a rich story in little space. Consider Safety for a moment. Not only can we quickly see that the United States is near the bottom with a score of 7.6 out of 10, but that most countries score within a narrow range, with two significant exceptions represented by the lowest bars on the left. Scanning the various measures, I quickly spot that our highest score relative to the other countries is Income (ranked second), but the score of 6.5 is much lower than the highest country. By hovering over the tallest bar a pop-up display tells me that Luxembourg leads the pack with a perfect Income score of 10.

My next question was “How do we compare to Luxembourg overall?” By selecting Luxembourg from the “Compare to…” drop-down list below the charts I was able to make this comparison with ease using the view below with Luxembourg’s bars highlighted but dimmer than those of the United States.

e573f better life index country comparison small Data Blooms in Beauty and Truth

If governance and education in Luxembourg scored more highly, I might be tempted to move.

Much more information about the United States appears on this screen, which I haven’t shown you, including links to related news stories and separate sections of detail about each measure, both in words and charts, those below:

d815a better life index specific indicators Data Blooms in Beauty and Truth

I’ll show just one more aspect of this rich story, then leave it to you to enjoy and learn from it on your own.

One of the key purposes of this infographic is to let us assign weights to the various measures of a better life to fit our own preferences and then see which countries offer the life that we seek. I weighted the measure arbitrarily and was shown the following view:

a96a8 better life index specific profile small Data Blooms in Beauty and Truth
Click to enlarge.

Weights are assigned by selecting from one to five dots to the right of each measure in the “Create Your Better Life Index.” Based on the weights that I assigned, the flower visualization now shows each country’s correlation to my preferences based on the vertical position of each (higher is better). I can make the comparison even easier by switching the sort order from alphabetically to ranked by score from lowest to highest.

I hope you can see from this brief description that the designers of this infographic achieved a marriage of form and function, beauty and usability, that did not subsume one to the other in an unequal partnership as many infographics do. It was designed and developed by Moritz Stefaner, Jonas Leist and Timm Kekeritz. I don’t know these fellows and know almost nothing about their other work, so I cannot vouch for its merits, but this one example speaks highly of their abilities and their respect for information. If you check on the background of Moritz Stefaner, you’ll find that he has a B.S. in Cognitive Science and an M.A. in Interface Design. His background provides an understanding of the human brain, which clearly directs him to display data in ways that our eyes can perceive and brains can comprehend with ease, speed, and accuracy. The other designers also have backgrounds that make them sensitive to issues of usability. They didn’t just make an infographic that was pretty and provided a little information in a semi-effective way. They could have made the flower petals spin around, but they knew better. Infographics don’t need to shout to get noticed; a welcoming smile and the promise of intelligent conversation is all they need. These guys created a piece of work that is beautiful, engaging, simple, easy to use, easy to understand, accurate, and deeply informative.

Work of this type differs from day-to-day examples of data visualization in two ways:

  1. It requires a great deal of graphical design expertise
  2. It requires a great deal of time

The Better Life Index was not produced in an hour or even a day. I’m sure that a great many hours of work went into its design and development. Only special circumstances warrant this amount of work and the resulting expense. When a story is important to a large number of people, it makes sense to invest this level of time and effort. Most uses of data visualization, however, feature information and insights that are important to relatively few people. We can’t afford several days of effort to produce them. We need skills and tools to produce them quickly and easily. We want them to be well designed—pleasing to the eye—but not necessarily beautiful.

Take care,

a96a8 Signature Data Blooms in Beauty and Truth

Article source: http://www.perceptualedge.com/blog/?p=1044

  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth
  • wp socializer sprite mask 16px Data Blooms in Beauty and Truth

Mondrian + MySQL Setup

0

Posted on : 06-07-2011 | By : Ben Stinner | In : Analytics
Tags: , ,

Introduction

Prerequisites

These are the applications that are needed before you can using Mondrian, follow on the link for more information on how to setup each application :


MySQL Foodmart Database Sample

149b3 foodmart sample wiki download Mondrian + MySQL Setup
Extract the script file using your favorite compression utility – 7zip is the one I would highly recommend.

Open command line prompt (Start | Run | type cmd | click OK)

cd C:mysqlbin
mysql.exe -uroot -e "create database Foodmart"
mysql.exe -uroot Foodmart  C:foodmart_mysql.sql
mysql.exe -uroot Foodmart -e "show tables"

You should see result like below if all running well…

+-------------------------------+
| Tables_in_foodmart            |
+-------------------------------+
| account                       |
| agg_c_10_sales_fact_1997      |
| agg_c_14_sales_fact_1997      |
| agg_c_special_sales_fact_1997 |
| agg_g_ms_pcat_sales_fact_1997 |
| agg_l_03_sales_fact_1997      |
| agg_l_04_sales_fact_1997      |
| agg_l_05_sales_fact_1997      |
| agg_lc_06_sales_fact_1997     |
| agg_lc_100_sales_fact_1997    |
| agg_ll_01_sales_fact_1997     |
| agg_pl_01_sales_fact_1997     |
| category                      |
| currency                      |
| customer                      |
| days                          |
| department                    |
| employee                      |
| employee_closure              |
| expense_fact                  |
| inventory_fact_1997           |
| inventory_fact_1998           |
| position                      |
| product                       |
| product_class                 |
| promotion                     |
| region                        |
| reserve_employee              |
| salary                        |
| sales_fact_1997               |
| sales_fact_1998               |
| sales_fact_dec_1998           |
| store                         |
| store_ragged                  |
| time_by_day                   |
| warehouse                     |
| warehouse_class               |
+-------------------------------+

Configuring and Running Tomcat

cd c:apache-tomcat-5.5.17bin
catalina run

Check your running server by browsing into http://localhost:8080. If everything works fine, our next step is to deploy Mondrian web application.

Deploying Mondrian

149b3 mondrian lib dir Mondrian + MySQL SetupExtract mondrian distribution package and goto lib directory. You will find mondrian.war file there.

149b3 place mondrian war Mondrian + MySQL Setup

Browse into your http://localhost:8080/mondrian and you shall get a Mondrian welcome page like below.

149b3 mondrian welcome page Mondrian + MySQL Setup

Configure JSP File

  • fourheir.jsp
  • mondrian.jsp
  • colors.jsp
  • arrows.jsp

Edit those files using your favorite text editor, and change following line :

 

jp:mondrianQuery id="query01"
jdbcDriver="sun.jdbc.odbc.JdbcOdbcDriver"
jdbcUrl="jdbc:odbc:MondrianFoodMart"
catalogUri="/WEB-INF/queries/FoodMart.xml"

..... this is your existing mdx query ....

/jp:mondrianquery

into your MySQL database configuration. For example …

jp:mondrianQuery id="query01"
jdbcDriver="com.mysql.jdbc.Driver"
jdbcUrl="jdbc:mysql://localhost/Foodmart?user=rootpassword="
catalogUri="/WEB-INF/queries/FoodMart.xml"

..... this is your existing mdx query ....

/jp:mondrianQuery

 

Browse Your Multi Dimensional Data

Now you are ready to to play with JPivot. Browse into your local mondrian host address : http://localhost:8080/mondrian,choose the first mondrian examples “JPivot pivot table”.

It will take some time as Mondrian will need to populate its initial cache before the view shows up.

You will then see a table which you can drill through in a hierarchical way and a heading toolbar which comprises of configuration icons.

396ee mondrian first jpivot sample Mondrian + MySQL Setup

To find more about configuring each sample to work well with above installation please refer to our wiki page at http://pentaho-en.phi-integration.com/mondrian/configuring-mondrian-sample.

 

Article source: http://business-intelligence.phi-integration.com/2008/04/mondrian-mysql-setup.html

  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup
  • wp socializer sprite mask 16px Mondrian + MySQL Setup

Mondrian as XMLA Provider

0

Posted on : 06-07-2011 | By : Ben Stinner | In : Analytics
Tags: , ,

From Mondrian’s documentationI find it quite simple to set up Mondrian as XMLA provider. But I didn’t find any adequate information on how to test it directly from Mondrian’s own bundled tool.

For any beginner, it will be hard and time consuming to find out whether the provider is already and rightly set up.

I write this article in order to help those with that problem, complementing Mondrian’s own documentation .

Setup

?xml version="1.0"?
DataSources
DataSource
DataSourceName
Provider=Mondrian;DataSource=MySQLTest;/DataSourceName
DataSourceDescriptionMondrian FoodMart Data
Warehouse/DataSourceDescription
URLhttp://localhost:8080/mondrian/xmla/URL
DataSourceInfo
Provider=mondrian;Jdbc=jdbc:mysql://localhost/foodmart;JdbcUser=root;JdbcPassword=;JdbcDrivers=com.mysql.jdbc.Driver;/DataSourceInfo
ProviderNameMondrian/ProviderName
ProviderTypeMDP/ProviderType
AuthenticationModeUnauthenticated/AuthenticationMode
Catalogs
Catalog name="FoodMart"
Definition/WEB-INF/queries/FoodMart.xml/Definition
/Catalog
/Catalogs
/DataSource
/DataSources

DataSourceName tag

Connection String

Validate Data Source

I assume that you already have Mondrian running under Tomcat in your local computer. Try browse to http://localhost:8080/mondrian/xmlaTest.jsp. Select “1.discoverDataSource” option from the combo list then click “show request” button until you see the XMLA construct like below.

After that, you might proceed by clicking “Run” to see if your XMLA provider – specified in your DataSourceName – is recognized.

A screen shot below indicated that Mondrian XMLA provider is recognized and ready to be sent any OLAP/MDX query.

17889 discover data sources soap reply Mondrian as XMLA Provider

Query Testing

Back to your XMLA test page, select “2. executeHR-tabular option list. Click on “Show Request” button.

17889 xmla query pt 2 Mondrian as XMLA Provider

Once you see the XMLA generated construct you need to modify one thing: DataSourceInfo entry.

Change the tag’s value of “DataSource=MondrianFoodMart;” into “DataSource=MySQLTest;“. Continue by clicking on “run” button.

If all going right you will have a returning XML SOAP result like below. This means that Mondrian has successfully executed your query.

39431.6712 Sheri Nowmer 39431.6712

Conclusion

Setup Mondrian as XMLA provider is easy and quite straightforward.

However, in order to test it we sometimes at a lost. Since we don’t have any adequate information provided with the bundled documentation. This article will serve as a complement for that.

Hope you find this blog entry helpful. Any comment or suggestion to improve this article is highly appreciated.

Article source: http://business-intelligence.phi-integration.com/2008/04/testing-mondrian-as-xmla-provider.html

  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider
  • wp socializer sprite mask 16px Mondrian as XMLA Provider

JPivot + MS Analysis 2000

0

Posted on : 06-07-2011 | By : Ben Stinner | In : Analytics
Tags: , ,

Introduction

JPivot is one of rich features OLAP clients in the market that comes up with web based interface. Its capability to run in multiple platform and compliant with XMLAstandard as its data source make JPivot a viable and affordable solution for every organizations that already implemented XMLA OLAP server but needed more robust client solution.

MS SQL Server 2000 and MS 2000 Analysis Server is one of the mostly wide used database and OLAP server in enterprise market. And since Microsoft is also the initiator in this XMLA technology, it is not surprising that MS Analysis Server also support the standard.

But the drawback is that both products don’t come out with any OLAP client. Hence, since JPivot is XMLA compliant we can use it nicely to fill the gap.

Setup IIS and MS 2000 Analysis Server

First you need to download Microsoft XMLA sdk and set it up with IIS and MS Analysis Server. I will not go through this step as you can see more detailed instructions in this MSDN article.

For my working sample I use XMLA 1.1 SDK version. And if you have installed, configured and running all the things correctly then try browse to msxisapi.dll from your XMLA virtual host. In my case my virtual directory name is set to xmla and located in my local desktop so I’ll browse to http://localhost/xmla/msxisapi.dll and should see result like the picture below

700bd testing iis xmla ie JPivot + MS Analysis 2000Figure 1: URL Testing for SQL Server 2000 XMLA Implementation
or if you are using Firefox you may get result like in figure 2.

e3699 testing iis xmla JPivot + MS Analysis 2000
Figure 2: URL Testing for SQL Server 2000 XMLA Implementation (Firefox)

Figure 3 is a screenshot of my IIS config for this xmla virtual directory.

e3699 iis setting for xmla JPivot + MS Analysis 2000
Figure 3: IIS xmla Virtual Directory

And for your complete reference this is the list of prerequisite applications that I use :

  • Windows XP Professional SP2
  • Microsoft Internet Information Services 5.1 that comes with Windows XP
  • Microsoft SQL 2000 SP4 with Microsoft Analysis installed
  • Java Development Kit 1.6
  • Apache Tomcat 5.5.17
  • JPivot 1.8

JPivot Query File

Listing 1 : salesCube.jsp

select
{[Measures].[Unit Sales], [Measures].[Store Cost]} on columns,
{[Customer].[All Customer]} ON rows
from Sales
MS Analysis Services Cube: Sales (via XMLA)

Pay attention to above listing for uri and catalog attribute of jp:xmlaQuery tag. For uri we will use the msixisapi.dll reference url that we already tested before. And for catalog I’m using Tutorial which is Ms Analysis Server catalog for Foodmart database sample. Make sure that in this example you already have setup Sales cube with Unit Sales and Store Cost measures and Customer dimension.


49ea5 jpivot mssql xmla JPivot + MS Analysis 2000Figure 4: JPivot with Axis in hierarchical mode

f44f3 jpivot char ms analyis xmla JPivot + MS Analysis 2000Figure 5: JPivot with Generated Bar Chart

Conclusion

Here I have shown how you can consume MS Analysis’s OLAP source using XMLA with a standard JPivot installation. Create a jsp file, specify your jp:xmlaQuery tag’s attributes and specify an MDX query. You now have all the rich features of JPivot.

Online Resources


Article source: http://business-intelligence.phi-integration.com/2008/04/jpivot-and-microsoft-analysis-service.html

  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000
  • wp socializer sprite mask 16px JPivot + MS Analysis 2000