This example builds a relational crosstab query with sex, height, weight on columns and age, name on rows.
Relational crosstabs behave just like plan relational data selections with regard to filters, ranking, totals and sorting. That is, all of these operations are applied prior to the aggregation of measures based on category values.
DataSelection query = buildClassroomDataSelection(); List resultItems = query.getResultItems(); DataItem sex = (DataItem) resultItems.get(0); DataItem age = (DataItem) resultItems.get(1); DataItem name = (DataItem) resultItems.get(2); DataItem height = (DataItem) resultItems.get(3); DataItem weight = (DataItem) resultItems.get(4); query.setResultItemRole(sex, Role.COLUMN); query.setResultItemRole(height, Role.COLUMN); query.setResultItemRole(weight, Role.COLUMN); query.setResultItemRole(age, Role.ROW); query.setResultItemRole(name, Role.ROW); //execute the query
The result of executing this query will be: