Thursday, March 13, 2008

Simple uses of OLAP

In Flex 3 OLAP APIs were introduced. And here is a sample showing how it can be used in simple data processing.

The sample shows how a companys product revenue over regions and markets can be compared. Click the "Create cube" button to process the input data which looks like this

  <market>Digital publishing</market>

and build the OLAP cube. Clicking on the "Query Revenue with Product by Region" button would display the result in OLAPDataGrid. The query returns the total revenue comparing product by region across all years (2005 and 2006 in the sample data case). The last row and last column display the totals by product and totals by region respectively.

Now different markets can be selected from the ComboBox and revenues from different markets can be compared.

The source can be found here.


_PSYCKIC_ said...

Very good the example, but have a problem with the source code ... onde this line.

private var pbar:progress = new progress;

Say can't find progress ... any ideia why?


_PSYCKIC_ said...
This comment has been removed by the author.
Marcos said...

I have the same problem:

private var pbar:progress = new progress;

What type is "progress"? I am using Flex 3.


Sreenivas said...

It was a simple class to show progress messages. Please remove references to it.

Iacob said...

Hey man..

Thanks for the sample. However, I must be too blind to see. How did you achieve the (All) item on both rows and columns axis? I cannot reproduce those on my OLAPDatagrid.

Thanks a lot,
Claudius Iacob

Sreenivas said...

If you take a look at the source it should be very obvious. One can use the members() method on an attribute and include it on both axis to get the (All).

Iacob said...

Thank you Sreenivas, I missed the ".members" thing indeed. BTW, for me it worked like a property rather than a method.

And, speaking of "(All)" do you know a way of localizing this string?

Thanks in advance,
Claudius Iacob

Sreenivas said...

You can set the allMemberName of OLAPHierarchy and use a derived version of OLAPAttribute class which overrides the get allMemberName() function.

Bubai said...

I am facing a problem regarding Olap Datagrid creation onload of page. I am having dynamic data and query and cube is like the olap datagrid developed by you.
TypeError: Error #1009: Cannot access a property or method of a null object reference
at mx.olap::CubeNodeBuilder/findNodeWithOneCell()
at mx.olap:: CubeNodeBuilder/optimizeCube()

I am using Version no of datavisualization.swc
I need to use this version only(no latest version).
In 3.2 the app is running fine. but in it is giving the error.
I will appreciate your help.