蒙德里安的星期几聚合

时间:2014-06-24 19:36:33

标签: mondrian saiku

我正在尝试将简化TimeDimension的Pentaho示例扩展为按星期聚合

这是提供的示例:

<Dimension name="Time" type="TimeDimension">
  <Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="dateid">
    <Table name="datehierarchy"/>
     <Level name="Year" column="year" uniqueMembers="true" levelType="TimeYears" type="Numeric"/>
     <Level name="Quarter" column="quarter" uniqueMembers="false" levelType="TimeQuarters"/>
     <Level name="Month" column="month" uniqueMembers="false" ordinalColumn="month" nameColumn="month_name" levelType="TimeMonths" type="Numeric"/>
     <Level name="Week" column="week_in_month" uniqueMembers="false" levelType="TimeWeeks"/>
     <Level name="Day" column="day_in_month" uniqueMembers="false" ordinalColumn="day_in_month" nameColumn="day_name" levelType="TimeDays" type="Numeric"/>
  </Hierarchy>
</Dimension>

(参考here

我修改过的Dimension看起来像这样:

<Dimension name="Time" type="TimeDimension">
  <Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="date_id">
    <Table name="dates"/>
    <Level name="Year" column="year" uniqueMembers="true" levelType="TimeYears" type="Numeric"/>
    <Level name="Month" column="month" uniqueMembers="false" ordinalColumn="month" nameColumn="month" levelType="TimeMonths" type="Numeric"/>
    <Level name="Week" column="week" uniqueMembers="false" levelType="TimeWeeks"/>
    <Level name="Day" column="day" uniqueMembers="true" ordinalColumn="day_in_week" nameColumn="day_of_week" levelType="TimeDays" type="Numeric"/>
  </Hierarchy>
</Dimension>

我遇到了一个挑战,即Saiku(作为Mondrian Cube的前端)坚持认为我的Day专栏应始终基于年 - 月 - 周的等级,这对于演练来说显然很好如果我只是想在白天进行聚合(例如,周一的平均销售额与周二的平均销售额),那就不行了。我尝试添加另一个维度,但无论我做什么,我最终得到N *天名称记录,其中N是我拥有的记录数量(理想情况下,我根据相关度量返回7行)

1 个答案:

答案 0 :(得分:0)

您是否尝试过单一级别的维度?

<Dimension name="Time" type="TimeDimension">
  <Hierarchy hasAll="true" allMemberName="All Periods" primaryKey="date_id">
    <Table name="dates"/>
    <Level name="Day" column="day" uniqueMembers="true" nameColumn="day_of_week" levelType="TimeDays" type="Numeric"/>
  </Hierarchy>
</Dimension>

我认为这可以通过Mondrian4和Saiku3解决,但目前我认为还有其他选择。