US and Worldwide: +1 (866) 660-7555
Results 1 to 5 of 5

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

  1. #1
    Fabien Carrion Guest

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

    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 (DOT) org
    http://lists.pentaho.org/mailman/listinfo/mondrian

  2. #2
    Julian Hyde Guest

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

    You're only getting the first measure because you're calling

    > Member member = hierarchy.getDefaultMember();


    To get all members of the measures dimension you could write

    > if (dimensions[n].isMeasures()) {
    > Hierarchy hierarchy = dimensions[n].getHierarchy();
    > SchemaReader schemaReader = schema.getSchemaReader();
    > Member[] members =

    schemaReader.getHierarchyRootMembers(hierarchy);

    Or, just generate MDX:

    > if (dimensions[n].isMeasures()) {
    > columnsMdx = " select NON EMPTY {" + dimensions[n].getUniqueName()

    + ".Members}
    > ON columns, ";


    Julian

    _______________________________________________
    Mondrian mailing list
    Mondrian (AT) pentaho (DOT) org
    http://lists.pentaho.org/mailman/listinfo/mondrian

  3. #3
    Fabien Carrion Guest

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

    On 6/10/07, Julian Hyde <julianhyde (AT) speakeasy (DOT) net> wrote:
    > You're only getting the first measure because you're calling
    >
    > > Member member = hierarchy.getDefaultMember();

    >
    > To get all members of the measures dimension you could write
    >
    > > if (dimensions[n].isMeasures()) {
    > > Hierarchy hierarchy = dimensions[n].getHierarchy();
    > > SchemaReader schemaReader = schema.getSchemaReader();
    > > Member[] members =

    > schemaReader.getHierarchyRootMembers(hierarchy);
    >
    > Or, just generate MDX:
    >
    > > if (dimensions[n].isMeasures()) {
    > > columnsMdx = " select NON EMPTY {" + dimensions[n].getUniqueName()

    > + ".Members}
    > > ON columns, ";


    with the MDX : "select NON EMPTY {" + dimensions[n].getUniqueName() +
    ".Members} ON columns, " I get all the measures. But I don't get the
    CalculatedMember. Is it the normal behaviour?

    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 (DOT) org
    http://lists.pentaho.org/mailman/listinfo/mondrian

  4. #4
    prakash tiwary Guest

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

    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 (DOT) 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 (DOT) org
    > http://lists.pentaho.org/mailman/listinfo/mondrian
    >


    _______________________________________________
    Mondrian mailing list
    Mondrian (AT) pentaho (DOT) org
    http://lists.pentaho.org/mailman/listinfo/mondrian

  5. #5
    Fabien Carrion Guest

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

    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 (DOT) 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 (DOT) 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 (DOT) org
    > > http://lists.pentaho.org/mailman/listinfo/mondrian
    > >

    >
    >
    > _______________________________________________
    > Mondrian mailing list
    > Mondrian (AT) pentaho (DOT) 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/
    _______________________________________________
    Mondrian mailing list
    Mondrian (AT) pentaho (DOT) org
    http://lists.pentaho.org/mailman/listinfo/mondrian

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •