Question


I have a problem that's really killing me. BTW I am new to Mdx and using olap4j Api to construct MDX Query. My problem is with the root element, Following is the code snippet:

     Query myQuery = new Query("Generated Query", sales); // where sales is an object of type cube.
QueryDimension productDimension = myQuery.getDimension("Product");

So now I have an object with dimension Product to use. I want some thing like this [Product].[All Products] to be part of the MdxQuery when I add productDimension to an axis. I can hardcode [All Products] but if the dimensionName passed is other than Product, say Stores it would be an issue. SO what I want is, whether it would be possible to fetch some thing get the names like [All Products] or [All Stores] or [definite Measures] which is equivalent to [All Measures] dynamically using olap4j?

PS: This is a method which takes in a dimension name and returns the first Member of the dimension like [Product].[All Products] if product is passed or [Measures].[All Measures/some Measures] if measures are passed.

Was it helpful?

Solution

I was able to figure out on how to get the root element To get some thing like All Products or basically all member name then I need to do some thing as shown below:

Say, I want the all member name for productDimension[object of type Dimension for product] then,

   Member allMember = productDimension.getDimension().getDefaultHierarchy().getRootMembers().get(0);

   productDimension.include(Selection.Operator.MEMBER, allMember);

By doing so allMember will be part of the Mdx Query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top