仅SSAS MDX YTD最后值

时间:2019-02-14 15:20:52

标签: ssas mdx

请您提供帮助:

事实表 a)实际情况

度量:每周流入,这是基础数据库表中的字段 [措施]。[每周流入量]

我使用以下方法计算YTD流入量

汇总 (   PeriodsToDate   (      [期末]。[期末]。[年],      [Period End]。[Period End] .CurrentMember   ),   [措施]。[_每周流入] )

我想显示一个新的计算得出的度量,该度量仅对显示实际流入的最后一条记录显示单个YTD流入值。 不得重复此操作,因为运行总计仅是一个值。请参见所附示例: Screen shot 如何使用计算出的度量来实现?请您提供一个例子吗?

日期维度:See screen shot

添加MDX后,请参阅屏幕截图3。不应显示带有粉红色背景的值。需要呈现绿色背景的人:Screen Shot 3

屏幕截图4:Additional Measure

屏幕截图5:Screen shot 5

Screen Shot 6

谢谢

1 个答案:

答案 0 :(得分:1)

因此,您需要在[Measures]。[_ Weekly Inflow]上运行BottomCount(1行),以获取最后一个具有非_Weekly Inflow值的元组,这将是计算得出的度量值。度量将一个案例检查[Period End]。[Period End]用户层次结构的当前值添加到上述度量的唯一值。我手边没有示例多维数据集,但查询结构将如下所示。

 with member Measures.[NewColumn]
as 
(bottomcount(
nonempty(
existing
{([Date].[Date].[Date].members)}
,[Measures].[_Weekly Inflow]),
1
).item(0).Name

member 
Measures.[YTD]
as 
case when [Period End].[Period End].currentmember.name=Measures.[NewColumn] then 
Aggregate ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember ), [Measures].[_Weekly Inflow] )
else 
null end

编辑

with member Measures.[NewColumn]
    as 
    (bottomcount(
    filter(
    existing
    {([Date].[Date].[Date].members)}
    ,[Measures].[_Weekly Inflow]>0),
    1
    ).item(0).Name

    member 
    Measures.[YTD]
    as 
    case when [Period End].[Period End].currentmember.name=Measures.[NewColumn] then 
    Aggregate ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember ), [Measures].[_Weekly Inflow] )
when 
[Period End].[Period End].currentmember.name=[Period End].[Period End].defaultmember then Aggregate ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember ), [Measures].[_Weekly Inflow] )
    else 
    null end

修改

    member 
    Measures.[YTD]
    as 
    case when [Period End].[Period End].currentmember.name=Measures.[NewColumn] then 
    Aggregate ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember ), [Measures].[_Weekly Inflow] )
when 
[Period End].[Period End].currentmember.name="Feburary 2018" then Aggregate ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember ), [Measures].[_Weekly Inflow] )
    else 
    null end