Daanse Tutorial - Measure Aggregator Nth
Data cubes have NTH measures.
Database Schema
The cube defined in this example is based on a single table that stores all the data. The table, named Fact, contains two columns: KEY and VALUE. The KEY column acts as a discriminator, while the VALUE column holds the measurements to be aggregated.
<roma:DatabaseSchema id="_databaseSchema">
<tables xsi:type="roma:PhysicalTable" id="_tab" name="Fact">
<columns xsi:type="roma:PhysicalColumn" id="_col_id" name="ID" type="Integer"/>
<columns xsi:type="roma:PhysicalColumn" id="_col_value" name="VALUE" type="Integer"/>
<columns xsi:type="roma:PhysicalColumn" id="_col_name" name="NAME"/>
</tables>
</roma:DatabaseSchema>Note: This is only a symbolic example. For the exact definition, see the Definition section.
Ordered Column
Represents a column with specific ordering information used in queries and result sets. OrderedColumn is typically used in OLAP contexts where explicit column ordering is required for query processing or result presentation. OrderedColumn uses ascending by default.
<roma:OrderedColumn id="_ordered_column_col_value" column="_col_value"/>Note: This is only a symbolic example. For the exact definition, see the Definition section.
Query
This example uses a TableQuery, as it directly references the physical table Fact.
<roma:TableQuery id="_query" table="_tab"/>Note: This is only a symbolic example. For the exact definition, see the Definition section.
Cube, MeasureGroup and NTH Aggragator Measures
In this example, multiple measures are defined. All measures reference the VALUE column and use the following aggregation functions:
- NTH1 – NTH1 .
- NTH2 – NTH2 .
- NTH3 – NTH3 .
- NTH4 – NTH4 .
- NTH5 – NTH5 .
- NTH6 – NTH6 .
- NTH7 – NTH7 .
<roma:PhysicalCube id="_cube" name="MeasuresAggregatorsCube" query="_query">
<dimensionConnectors foreignKey="roma:PhysicalColumn _col_id" dimension="roma:StandardDimension _diml" overrideDimensionName="Dim" id="_dc_dim"/>
<measureGroups>
<measures xsi:type="roma:NthAggMeasure" id="_measure1" name="NthAgg1" column="_col_value" orderByColumns="_ordered_column_col_value" n="1"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure2" name="NthAgg2" column="_col_value" orderByColumns="_ordered_column_col_value" n="2"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure3" name="NthAgg3" column="_col_value" orderByColumns="_ordered_column_col_value" n="3"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure4" name="NthAgg4" column="_col_value" orderByColumns="_ordered_column_col_value" n="4"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure5" name="NthAgg5" column="_col_value" orderByColumns="_ordered_column_col_value" n="5"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure6" name="NthAgg6" column="_col_value" orderByColumns="_ordered_column_col_value" n="6"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure7" name="NthAgg7" column="_col_value" orderByColumns="_ordered_column_col_value" n="7"/>
</measureGroups>
</roma:PhysicalCube>Note: This is only a symbolic example. For the exact definition, see the Definition section.
Definition
This file represents the complete definition of the catalog.
<?xml version="1.0" encoding="UTF-8"?>
<xmi:XMI xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:roma="https://www.daanse.org/spec/org.eclipse.daanse.rolap.mapping">
<roma:OrderedColumn id="_ordered_column_col_value" column="_col_value"/>
<roma:Catalog description="Nth value aggregation functions" name="Daanse Tutorial - Measure Aggregator Nth" cubes="_cube" dbschemas="_databaseSchema"/>
<roma:DatabaseSchema id="_databaseSchema">
<tables xsi:type="roma:PhysicalTable" id="_tab" name="Fact">
<columns xsi:type="roma:PhysicalColumn" id="_col_id" name="ID" type="Integer"/>
<columns xsi:type="roma:PhysicalColumn" id="_col_value" name="VALUE" type="Integer"/>
<columns xsi:type="roma:PhysicalColumn" id="_col_name" name="NAME"/>
</tables>
</roma:DatabaseSchema>
<roma:TableQuery id="_query" table="_tab"/>
<roma:Level id="_level" name="Value" column="_col_value"/>
<roma:ExplicitHierarchy id="_hierarchy_Hierarchy" name="Hierarchy" hasAll="false" primaryKey="_col_id" query="_query" levels="_level"/>
<roma:StandardDimension id="_diml" name="Diml" hierarchies="_hierarchy_Hierarchy"/>
<roma:PhysicalCube id="_cube" name="MeasuresAggregatorsCube" query="_query">
<dimensionConnectors foreignKey="_col_id" dimension="_diml" overrideDimensionName="Dim" id="_dc_dim"/>
<measureGroups>
<measures xsi:type="roma:NthAggMeasure" id="_measure1" name="NthAgg1" column="_col_value" orderByColumns="_ordered_column_col_value" n="1"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure2" name="NthAgg2" column="_col_value" orderByColumns="_ordered_column_col_value" n="2"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure3" name="NthAgg3" column="_col_value" orderByColumns="_ordered_column_col_value" n="3"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure4" name="NthAgg4" column="_col_value" orderByColumns="_ordered_column_col_value" n="4"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure5" name="NthAgg5" column="_col_value" orderByColumns="_ordered_column_col_value" n="5"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure6" name="NthAgg6" column="_col_value" orderByColumns="_ordered_column_col_value" n="6"/>
<measures xsi:type="roma:NthAggMeasure" id="_measure7" name="NthAgg7" column="_col_value" orderByColumns="_ordered_column_col_value" n="7"/>
</measureGroups>
</roma:PhysicalCube>
</xmi:XMI>Tutorial Zip
This file contains the data-tables as csv and the mapping as xmi file.