我有一个蒙德里安魔方与“个人”。我需要为每个个体添加两个类别,并为这些类别提供一个概率数值。该数据属于一个新的维度“类别”。数据来自Postgres 9物化视图,其概率在Postgres中为“数值”类型。
但是,当我试图将数据显示为“数值”时,带有十进制值的行根本不会显示。
如果我将概率取为百分比并舍入它们的值,那么所有的行都会正确地显示。
<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>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]报告产出:
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"发布于 2019-07-15 09:24:29
简单地说:在Mondrian中,不能使用小数作为水平键。
层次结构级别必须是离散的,而数值不是离散的。所以蒙德里安总是把十进制部分截掉。
相反,应该将数字值作为字符串级别的属性。
例如,
<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>然后,这些属性可用于定义MDX查询计算的度量值。但它们不能直接用作水平。
或者,您可以将值截断为固定数量的小数,并使用LevelType作为字符串,但这会有些尴尬。
https://stackoverflow.com/questions/56970283
复制相似问题