MDX不显示最新版本的数据

时间:2018-01-04 09:59:25

标签: sql sql-server ssas mdx

我需要一些帮助才能找出我在MDX中遇到的问题。我想显示度量的每个周期的最后版本,即使该值为NULL。但是我的代码显示了最后一个非空版本。

示例:

My problem

这是我的代码:(表格中的可见度量是MNY_ENCOURS)

SCOPE([DIM Version].[VCR BK Version].[All]);
    [Measures].[MNY_AA_Total] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[MNY_AA_Total])));
    [Measures].[MNY_ENCOURS] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[MNY_ENCOURS])));
    [Measures].[MNY_Flottement] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[MNY_Flottement])));
    [Measures].[MNY_Montant_Cale] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[MNY_Montant_Cale])));
    [Measures].[MNY_VARIATION_ENCOURS] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[MNY_VARIATION_ENCOURS])));
    [Measures].[V FCT Collecte Count] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[V FCT Collecte Count])));
    [Measures].[CONFI_FLUX] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[CONFI_FLUX])));
    [Measures].[CONFI_STOCKS] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[CONFI_STOCKS])));
    [Measures].[Declarant_Distinct_Count] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[Declarant_Distinct_Count])));
    [Measures].[MNY_FLUX_CALCULE] = tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[MNY_FLUX_CALCULE])));
    [Measures].[PART_FLUX_Trimestriel]=tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[PART_FLUX_Trimestriel])));
    [Measures].[PART_STOCKS]= tail(filter([DIM Version].[VCR BK Version].[All], not isempty([Measures].[PART_STOCKS])));                  
END SCOPE;
你能帮帮我吗?谢谢

2 个答案:

答案 0 :(得分:1)

为什么不从这个模式中移出每个度量:

...
[Measures].[MNY_ENCOURS] 
  = TAIL(
      FILTER(
        [DIM Version].[VCR BK Version].[All]
      , not isempty([Measures].[MNY_ENCOURS])
    )
...

为每个元组添加一个元组,如下所示:

...
[Measures].[MNY_ENCOURS] 
  = (
      tail([DIM Version].[VCR BK Version].[All].MEMBERS).ITEM(0).ITEM(0)
     ,[Measures].[MNY_ENCOURS]
    )
...

答案 1 :(得分:0)

最后我这样做了:

<rt>