AnsweredAssumed Answered

Mondrian/Olap4J return a single member per position

Question asked by Pablo Schor on Jun 5, 2018

Given the following FoodMart MDX statement executed with OLAP4J/Mondrian, I'm expecting the column headers to return N members for each position according to the hierarchy. Instead, it returns a single member (the bottom one). In the case of [Store State], I'm expecting two members, for example 'Canada' and 'BC', instead `position.getMembers` only returns 'BC'.

 

 

Is there anything wrong in the way the axes are printed?

 

 

Code in Scala:

 

       val select = "SELECT " +
                    "[Measures].[Count] ON ROWS,  " +
                    "[Store].[Store State].Members ON COLUMNS " +
                    "FROM [HR] "
                    
       val olapConnection = pool.getConnection
       val statement = olapConnection.createStatement
       val cellSet = statement.executeOlapQuery(select)
       printCellSet(cellSet)
       pool.close(olapConnection)
     ......
     ......
    def printCellSet (cellSet: CellSet) = {
      
       val cellSetAxes = cellSet.getAxes.asScala
       val columnsAxis = cellSetAxes(Axis.COLUMNS.axisOrdinal)
       for ( colPosition <- columnsAxis.getPositions.asScala) yield {
            val members = colPosition.getMembers.asScala
            println(members)
       }
       
       var cellOrdinal = 0
       val rowsAxis = cellSetAxes(Axis.ROWS.axisOrdinal)
       for ( rowPosition <- rowsAxis.getPositions.asScala) yield {
            val members = rowPosition.getMembers.asScala
            println(members)
            
            // for each row, loop through every column to get the cell value
            for ( colPosition <- columnsAxis.getPositions.asScala) yield {
              
              val cell = cellSet.getCell(cellOrdinal)
              cellOrdinal = cellOrdinal + 1
              println(cell.getFormattedValue)
              
            }
        }
     }

Outcomes