[英]SSAS MDX YTD Last Value only
Please could you assist:请您帮忙:
fact table a) Actuals事实表 a) 实际值
Measure: Weekly Inflow this is the field within the underlying database table [Measures].[Weekly Inflow] Measure: Weekly Inflow 这是基础数据库表 [Measures].[Weekly Inflow] 中的字段
I calculate YTD Inflow using the following我使用以下方法计算 YTD 流入
Aggregate ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember ), [Measures].[_Weekly Inflow] )聚合 ( PeriodsToDate ( [Period End].[Period End].[Year], [Period End].[Period End].CurrentMember), [Measures].[_Weekly Inflow])
I want to display a new calculated measure which will show me a single YTD Inflow value only for the very last record where an actual inflow is shown.我想显示一个新的计算度量,它将显示一个 YTD 流入值,仅用于显示实际流入的最后一条记录。 This must not be repeated as a running total just a single value.这不能作为一个运行总计而重复,只是一个单一的值。 Please see the example attached: Screen shot How can i achieve this using a calculated measure?请参阅所附示例:屏幕截图我如何使用计算的度量来实现此目的? Please could you provide an example?请你能举个例子吗?
Date dimension: See screen shot日期维度:见屏幕截图
Please see screen shot 3 after adding the MDX.请在添加 MDX 后查看屏幕截图 3。 The values with the pink background should not be shown.不应显示粉红色背景的值。 Those with a green background need to be presented: Screen Shot 3需要呈现绿色背景的:屏幕截图3
Screen shot 4: Additional Measure屏幕截图 4:附加措施
Screen shot 5: Screen shot 5屏幕截图 5:屏幕截图 5
Thank you谢谢
So you need to run BottomCount (1 row) on your [Measures].[_Weekly Inflow] to get the last tuple that has a non null value of _Weekly Inflow,this will be a calculated measure .Next, in your YTD measure add a case that checks the current value of the [Period End].[Period End] user hierarchy to the only value of the above measure.因此,您需要在 [Measures].[_Weekly Inflow] 上运行 BottomCount(1 行)以获取具有 _Weekly Inflow 非空值的最后一个元组,这将是一个计算度量。接下来,在您的 YTD 度量中添加一个检查 [Period End].[Period End] 用户层次结构的当前值到上述度量的唯一值的情况。 I dont have a sample cube at hand but the query structure will be like below.我手头没有示例多维数据集,但查询结构将如下所示。
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
Edit编辑
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
Edit编辑
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
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.