postgresqlpentahohierarchycubemondrian

Reports on Pentaho Business Analytics not showing decimal numbers


I have a Mondrian Cube with "individuals". I need to add two categories associated to each individual, with a probability numeric value for these categories. This data is in a new dimension "Categories". The data comes from a Postgres 9 Materialized View and the probabilities are of type "numeric" in Postgres.

However, when I try to show the data as "numeric", the rows with decimal values are not shown at all.

If I take the probabilities to percentages and round their values, then all the rows are shown correctly.

<Dimension name="Categories">
    <Hierarchy name="Category1" visible="true" hasAll="true" primaryKey="id" caption="Categories">
      <Table name="individuals_mv" schema="public"/>
      <Level  approxRowCount="6000" name="Category1" visible="true" column="category_1" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"/>
    </Hierarchy>
    <Hierarchy name="CategoryProbability1" visible="true" hasAll="true" primaryKey="id" caption="Categories">
      <Table name="individuals_mv" schema="public"/>
      <Level  approxRowCount="6000" name="CategoryProb1" visible="true" column="category_prob_1" type="Numeric" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"/>
    </Hierarchy>
    <Hierarchy name="Category2" visible="true" hasAll="true" primaryKey="id" caption="Categories">
      <Table name="individuals_mv" schema="public"/>
      <Level  approxRowCount="6000" name="Category2" visible="true" column="category_2" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"/>
    </Hierarchy>
    <Hierarchy name="CategoryProbability2" visible="true" hasAll="true" primaryKey="id" caption="Categories">
      <Table name="individuals_mv" schema="public"/>
      <Level  approxRowCount="6000" name="CategoryProb2" visible="true" column="category_prob_2" type="Numeric" uniqueMembers="false" levelType="Regular" hideMemberIf="Never"/>
    </Hierarchy>
 </Dimension>

Content of individuals_mv:

individual  category_1  category_prob_1 category_2  category_prob_2
61411120    [NULL]      [NULL]          [NULL]      [NULL]
10658560    [NULL]      [NULL]          [NULL]      [NULL]
60652135    [NULL]      [NULL]          [NULL]      [NULL]
10657820    "C1"        0.32846         "C3"        0.1957235187
60873351    "C1"        0.33012354      "C2"        0.2763309777
61399718    [NULL]      [NULL]          [NULL]      [NULL]
61378272    [NULL]      [NULL]          [NULL]      [NULL]
61378554    [NULL]      [NULL]          [NULL]      [NULL]

Report output:

Individual       Category1            CategoryProb1        Category2            CategoryProb2
"10658560"      "Not Available"      "Not Available"      "Not Available"      "Not Available"
"60652135"      "Not Available"      "Not Available"      "Not Available"      "Not Available"
"61378272"      "Not Available"      "Not Available"      "Not Available"      "Not Available"
"61378554"      "Not Available"      "Not Available"      "Not Available"      "Not Available"
"61399718"      "Not Available"      "Not Available"      "Not Available"      "Not Available"
"61411120"      "Not Available"      "Not Available"      "Not Available"      "Not Available"

Solution

  • To put it simply: you cannot use decimals as level keys in Mondrian.

    Hierarchy levels must be discrete, and numeric values are not. So Mondrian will always truncate the decimal part out.

    You should instead put the numeric values as properties of the string levels.

    For example,

    <Dimension name="Categories">
        <Hierarchy name="Category1" visible="true" hasAll="true" primaryKey="id" caption="Categories">
          <Table name="individuals_mv" schema="public"/>
          <Level  approxRowCount="6000" name="Category1" visible="true" column="category_1" type="String" uniqueMembers="false" levelType="Regular" hideMemberIf="Never">
                <Property name="CategoryProb1" column="category_prob_1" type="Numeric" />
          </Level>
        </Hierarchy>
    (...)
     </Dimension>
    

    Those properties can then be used to define calculated measures by the MDX query. But they cannot be directly used as levels.

    Alternatively, you can truncate the values to a fixed number of decimals and use the LevelType as string, but that will be somewhat awkward.