[Mondrian] How to explore the dimension object used as a measure?

Fabien Carrion fabien.carrion at gmail.com
Mon Jun 11 14:36:04 EDT 2007


Hi,

I used both way, trying to get the measures names by
mondrianSchema.getHierarchyRootMembers(dimension.getHierarchies()[0]);
and the olap query.

I get the normal measures, which are from the fact table.
But I don't get the calculated measures.

So if my cube is:

    <VirtualCube name="TrainingEmployeeCube">
        <VirtualCubeDimension name="Training"/>
        <VirtualCubeDimension name="Project"/>
        <VirtualCubeMeasure cubeName="EmployeeCount"
name="[Measures].[Count Employee]"/>
        <VirtualCubeMeasure cubeName="TrainingCount"
name="[Measures].[Count Training]"/>
        <VirtualCubeMeasure cubeName="TrainingEmployee"
name="[Measures].[Count TrainingEmployee]"/>
        <CalculatedMember name="Percentage of trained Employee"
dimension="Measures">
                 <Formula>( [Measures].[Count TrainingEmployee] ) / (
[Measures].[Count Training] * [Measures].[Count Employee] )</Formula>
                 <CalculatedMemberProperty name="FORMAT_STRING"
value="###.##%"/>
        </CalculatedMember>
    </VirtualCube>


I get [Measures].[Count Employee], [Measures].[Count Training],
[Measures].[Count TrainingEmployee]. But I don't get
[Measures].[Percentage of trained Employee]

Is there a specific way for the Calculated Members?

Thanks

On 6/11/07, prakash tiwary <prakash.tiwary at gmail.com> wrote:
> Fabien,
>    If you use hierarchy.getDefaultMember(), it will not solve your purpose.
> I have done in following ways.
> Try this.
>     //     Measures are always returned as zeroth dimension
>             Dimension dimension = cube.getDimensions()[0];
>
>             mondrianSchema = connection.getSchemaReader()
>
>             //     All Measure names belong to zeroth hierarchy
>             RolapMember[] measures = (RolapMember[])
> mondrianSchema.getHierarchyRootMembers
> (dimension.getHierarchies()[0]);
>
>             for(int i = 0 ; i < measures.length ; i++)
>             {
>
> System.out.println((measures[i].getUniqueName()));
>             }
>
> Feel free to come back to me.
>
> Thanks & Regards
> Prakash
>
> On 6/10/07, Fabien Carrion <fabien.carrion at gmail.com> wrote:
> >
> > Hi,
> >
> > I would like to explore the Dimension object when it is used as a measure.
> >
> > So I do this:
> >
> > Schema schema = connection.getSchema();
> > Cube cubes[] = schema.getCubes();
> > for (int n = 0; n < cubes.length; n++) {
> >   if (cubes[n].getName().equals(cubeDefaultName)) {
> >     cube = cubes[n];
> >     break;
> >   }
> > }
> > Dimension dimensions[] = cube.getDimensions();
> > for (int n = 0; n < dimensions.length; n++) {
> >   Hierarchy hierarchy = dimensions[n].getHierarchy();
> >   Member member = hierarchy.getDefaultMember ();
> >   if (dimensions[n].isMeasures()) {
> >     measuresMdx = "";
> >     columnsMdx = " select NON EMPTY {" + member.getUniqueName() + "}
> > ON columns, ";
> >   } else {
> >     if (rowsMdx.length () > 0) {
> >       rowsMdx.append(", ");
> >     }
> >   rowsMdx.append(member.getUniqueName());
> >   }
> > }
> > StringBuffer result = new StringBuffer(measuresMdx.length() +
> > columnsMdx.length() + rowsMdx.length () + 50);
> >
> > result.append(measuresMdx).append(columnsMdx).append("NON
> EMPTY
> > {(").append(rowsMdx).append(")} ON rows ").append("from [" +
> > cube.getName() + "]");
> >
> >
> > This code just display me one measure. I don't find out where are the
> > other measures. How can I display them?
> >
> > I am using mondrian 2.3.2.8944 in a java program.
> >
> > Thanks
> >
> > --
> > Fabien Carrion
> >
> > ()  Campagne du ruban ASCII -- Contre les mails en html
> > /\  contre les pieces-jointes Microsoft
> > Web: http://fabien.carrion.free.fr/
> > _______________________________________________
> > Mondrian mailing list
> > Mondrian at pentaho.org
> > http://lists.pentaho.org/mailman/listinfo/mondrian
> >
>
>
> _______________________________________________
> Mondrian mailing list
> Mondrian at pentaho.org
> http://lists.pentaho.org/mailman/listinfo/mondrian
>
>


-- 
Fabien Carrion

()  Campagne du ruban ASCII -- Contre les mails en html
/\  contre les pieces-jointes Microsoft
Web: http://fabien.carrion.free.fr/



More information about the Mondrian mailing list