Mondrian:在针对VirtualCube的查询中忽略切片器轴

时间:2016-11-02 14:44:32

标签: mondrian

我创建了一个VirtualCube,在我的架构中组合了另外两个Cubes。 但是,似乎忽略了针对此VirtualCube的查询的切片器轴。

此查询返回预期结果:

SELECT
  NON EMPTY {
    [Measures].[FOB],
    [Measures].[CIF]
  } ON 0,
  NON EMPTY [Date].[Year].Members ON 1
FROM [exports_and_imports]

这个结果返回与前一个相同的结果,这是不正确的:

SELECT
  NON EMPTY {
    [Measures].[FOB],
    [Measures].[CIF]
  } ON 0,
  NON EMPTY [Date].[Year].members ON 1
FROM [exports_and_imports]
WHERE (
        [Geography].[Washington]
      )

但是,应用于Date的切片器可以工作:

  SELECT 
  NON EMPTY { 
    [Measures].[FOB], 
    [Measures].[CIF] 
  } ON 0 
FROM [exports_and_imports] 
WHERE ( 
        [Date].[Year].&[2005]:date.year.&[2014] 
      ) 

我的架构的编辑版本:

<Schema name="datachile">
  <Dimension name="Date" type="TimeDimension">...</Dimension>

  <Dimension name="Geography">...</Dimension>

  <Dimension name="Country">...</Dimension>

  <Dimension name=“HS”>...</Dimension>

  <Cube name="exports">
    <DimensionUsage name="Date" source="Date" foreignKey="date_id" />
    <DimensionUsage name="Destination Country" source="Country" foreignKey="country_dest_id" />
    <DimensionUsage name="Export Geography" source="Geography" foreignKey="exporter_comuna_id" />
    <DimensionUsage name="Export HS" source="HS" foreignKey="hs_level3" />

    <Measure name="FOB US" column="fob_us" aggregator="sum" />
  </Cube>

  <Cube name="imports">
    <DimensionUsage name="Date" source="Date" foreignKey="date_id" />
    <DimensionUsage name="Origin Country" source="Country" foreignKey="country_origin_id" />
    <DimensionUsage name="Import Geography" source="Geography" foreignKey="importer_comuna_id" />
    <DimensionUsage name="Import HS" source="HS" foreignKey="hs_6digits" />

    <Measure name="CIF US" column="cif_us" aggregator="sum" />
  </Cube>


  <VirtualCube name="exports_and_imports">
    <CubeUsages>
      <CubeUsage cubeName="exports" ignoreUnrelatedDimensions="true" />
      <CubeUsage cubeName="imports" ignoreUnrelatedDimensions="true" />
    </CubeUsages>

    <VirtualCubeDimension name="Date" />
    <VirtualCubeDimension name="Geography" />
    <VirtualCubeDimension name="HS" />

    <VirtualCubeMeasure cubeName="exports" name="[Measures].[FOB US]" />
    <VirtualCubeMeasure cubeName="imports" name="[Measures].[CIF US]"  />

    <CalculatedMember name="FOB" dimension="Measures">
      <Formula>ValidMeasure([Measures].[FOB US])</Formula>
    </CalculatedMember>

    <CalculatedMember name="CIF" dimension="Measures">
      <Formula>ValidMeasure([Measures].[CIF US])</Formula>
    </CalculatedMember>
  </VirtualCube>
</Schema>

1 个答案:

答案 0 :(得分:1)

在你的任何立方体中都没有称为“地理”的维度。有一个名为“进口地理”,另一个名为“出口地理”。您的虚拟多维数据集正在尝试使用这两个多维数据集都没有的Geography维度,但由于层次结构是使用hasAll="true"定义的,因此维度默认为两个多维数据集中的allMember。

您需要在虚拟多维数据集中定义导出和导入地理位置维度,并且切片器必须

Union( [Import Geography].[Washington] * [Export Geography].[All], [Import Geography].[All] * [Export Geography].[Washington] )

(如果您所追求的是“在华盛顿州以外的地方向我展示总价值”。