【问题标题】:How can I configure dimension to ignore specific value如何配置维度以忽略特定值
【发布时间】:2016-03-22 15:57:08
【问题描述】:

我有一个现有的事实表,我需要使用 Mondrian Schema 对 OLAP 多维数据集进行建模。
事实表有几列与维度表的主键,但不幸的是有维度值为“0”的行,约定为“all”

只有一维的示例:student_id:

| student_id |       exams
+------------+-------------
|         0  |          23
|     20131  |          15
|     20168  |           2
|     20468  |           6

学生桌

  id   | name
-------+-----------
 20131 | John
 20168 | Daid
 20468 | Peter
 20629 | Paul
 22344 | Micheal

我的架构是:

<Schema name="students">
  <Dimension type="StandardDimension" visible="true" name="StudentDimension">
    <Hierarchy name="Student" visible="true" hasAll="true" primaryKey="id">
      <Table name="student" schema="public" alias="" />
      <Level name="Nome" visible="true" column="name" type="String" uniqueMembers="false" levelType="Regular" />
    </Hierarchy>
  </Dimension>
  <Cube name="studentCube" visible="true" cache="true" enabled="true">
    <Table name="students_cube" schema="public" />
    <DimensionUsage source="StudentDimension" name="StudentUsage" visible="true" foreignKey="student_id" />
    <Measure name="Exams" column="exams" datatype="Numeric" aggregator="sum" visible="true" />
  </Cube>
</Schema>

我的问题是执行查询:

SELECT 
    {[Measures].[Exams]} ON COLUMNS,
    {[StudentUsage.Student].[All StudentUsage.Student]} ON ROWS 
FROM [studentCube]

我的结果是“46”:所有考试的总和包括 student_id = 0 的行。

我想在架构中排除与值为“0”的维度关联的度量。有可能吗?

【问题讨论】:

    标签: mdx business-intelligence olap olap-cube mondrian


    【解决方案1】:

    你可以试试这个:

    SELECT 
        {[Measures].[Exams]} ON COLUMNS,
        {
         [StudentUsage.Student].[All StudentUsage.Student] - 
         [StudentUsage.Student].[All StudentUsage.Student].&[0]
        } ON ROWS 
    FROM [studentCube]
    

    或者试试:

    SELECT 
        {[Measures].[Exams]} ON COLUMNS,
        EXCEPT
           (
            [StudentUsage.Student].[All StudentUsage.Student] , 
            [StudentUsage.Student].[All StudentUsage.Student].&[0]
           ) ON ROWS 
    FROM [studentCube]
    

    【讨论】:

    • 我收到此错误:“在多维数据集 'studentCube' 中找不到 MDX 对象 '[StudentUsage.Student].[All StudentUsage.Student].&[0]'”
    • 这个成员的全限定成员名是什么.."存在维度值为"0"的行,约定为"all""?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-11-21
    • 2019-06-22
    • 2011-05-09
    • 2011-07-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多