1

我正在尝试扩展简单 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>

(参考这里

我修改后的 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(用作蒙德里安立方体的前端)坚持认为我的Day专栏应该始终基于年-月-周的层次结构,这显然适合向下钻取,但如果我只想要聚合则不行按天计算(例如星期一与星期二的平均销售额)。我尝试添加另一个维度,但无论我做什么,我最终都会得到 N * 天名称记录,其中 N 是我拥有的记录数(理想情况下,我会根据相关度量返回 7 行)

4

1 回答 1

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 解决,但目前我认为没有其他选择。

于 2014-06-26T18:54:59.753 回答