Olap4J query ordering by columns first

26 views
Skip to first unread message

Pablo S

unread,
Jul 13, 2016, 7:20:39 PM7/13/16
to pivot4j-list
Hi Xavier, I'm comparing the result of the code below with JPivot, and instead of showing cells by row/column, it is showing columns/rows. How to get cells ordered by rows/columns?

Thanks
Pablo

            model.setMdx(mdx);
            model.initialize();
            val cellSet = model.getCellSet();
            val axes = cellSet.getAxes();
            val rows = axes.get(0);
            val columns = axes.get(1);
            val rowPositions = rows.getPositions();
            val rowLength = rowPositions.length
            val colPositions = columns.getPositions();
            val colLength = colPositions.length

            val table = Array.ofDim[Double](rowLength,colLength)
            
            for {
                rowPos <- rows
                colPos <- columns
            }
            println ( cellSet.getCell(rowPos,colPos).getDoubleValue )

Pablo S

unread,
Jul 13, 2016, 8:03:33 PM7/13/16
to pivot4j-list
What confuses me is that here (olap4j) it says that rows are accessed with cellSet.getAxes().get(0) and here (pivot4j) it says that are accessed with cellSet.getAxes().get(1)

Xavier Cho

unread,
Jul 14, 2016, 11:36:08 AM7/14/16
to pivot4...@googlegroups.com
Hi Pablo,

I think the Olap4J documentation actually confirms Pivot4J's usage:

> The first axis in a CellSet will return Axis.COLUMNS, the second Axis.ROWS,
> and so forth, as described by the Axis.axisOrdinal() method of the Axis
> enumeration.

In your source, I can see that you assigned an axis with ordinal value of 0
as the rows, which is incorrect according to both Olap4J and Pivot4J's
documentation.

Please let me know if I have missed something.

Cheers,
Xavier

2016년 7월 13일 수요일 오후 5시 3분 32초 KST에 Pablo S 님이 쓴 글:
> What confuses me is that here
> <http://www.olap4j.org/api/org/olap4j/CellSetAxis.html> (olap4j) it says
> that rows are accessed with cellSet.getAxes().get(0) and here
> <http://www.pivot4j.org/usage.html>(pivot4j) it says that are accessed with

Pablo S

unread,
Jul 14, 2016, 12:03:11 PM7/14/16
to pivot4j-list
Thanks, this clarifies
Reply all
Reply to author
Forward
0 new messages