有什么方法可以在 MDX 中进行动态累积测量?
Is there any ways to dynamic cumulative measure in MDX?
我要累加的所有度量都具有相同的公式。那么,有什么方法可以使用函数之类的东西或计算度量中的任何东西来解决这个问题吗?
有两种方法可以达到你的目的:
1- 第一个解决方案基于使用商业智能向导将时间智能添加到您的解决方案。
The time intelligence enhancement is a cube enhancement that adds time calculations (or time views) to a selected hierarchy. This enhancement supports the following categories of calculations:
List item
Period to date.
Period over period growth.
Moving averages.
Parallel period comparisons.
向导会让您选择要应用的计算和度量。
访问:http://www.ssas-info.com/analysis-services-articles/62-design/2465-ssas-time-intelligence-wizard
2-使用维度table来计算你的计算,这个解决方案比较复杂,但非常强大,是最佳实践之一。
The first step is to create a new physical dimension, with real
members for each of the calculations we're going to need. We don't
actually need to create a table in our data warehouse for this
purpose, we can do this with an SQL view like this
CREATE VIEW DateTool AS SELECT ID_Calc = 1, Calc = 'Real Value' UNION ALL SELECT ID_Calc = 2, Calc = 'Year To Date'
Next, we need to add this view to our DSV and create a dimension based
on it. The dimension must have one hierarchy and this hierarchy must
have its IsAggregatable property set to False. The DefaultMember
property of this hierarchy should then be set to the Real Value
member. Giving this dimension a name can be quite difficult, as it
should be something that helps the users understand what it does –
here we've called it Date Tool. It needs no relationship to any
measure group at all to work.
Our next task is to overwrite the value returned by each member so
that they return the calculations we want. We can do this using a
simple SCOPE statement in the MDX Script of the cube:
此代码可让您为所有度量创建 YEAR-TO-DATE 聚合。
SCOPE ([Date Tool].[Calculation].[Year To Date]); THIS = AGGREGATE ( YTD ([Date Order].[Calendar].CurrentMember), [Date Tool].[Calculation].[Real Value]); END SCOPE;
我要累加的所有度量都具有相同的公式。那么,有什么方法可以使用函数之类的东西或计算度量中的任何东西来解决这个问题吗?
有两种方法可以达到你的目的:
1- 第一个解决方案基于使用商业智能向导将时间智能添加到您的解决方案。
The time intelligence enhancement is a cube enhancement that adds time calculations (or time views) to a selected hierarchy. This enhancement supports the following categories of calculations:
List item
Period to date.
Period over period growth.
Moving averages.
Parallel period comparisons.
向导会让您选择要应用的计算和度量。
访问:http://www.ssas-info.com/analysis-services-articles/62-design/2465-ssas-time-intelligence-wizard
2-使用维度table来计算你的计算,这个解决方案比较复杂,但非常强大,是最佳实践之一。
The first step is to create a new physical dimension, with real members for each of the calculations we're going to need. We don't actually need to create a table in our data warehouse for this purpose, we can do this with an SQL view like this
CREATE VIEW DateTool AS SELECT ID_Calc = 1, Calc = 'Real Value' UNION ALL SELECT ID_Calc = 2, Calc = 'Year To Date'
Next, we need to add this view to our DSV and create a dimension based on it. The dimension must have one hierarchy and this hierarchy must have its IsAggregatable property set to False. The DefaultMember property of this hierarchy should then be set to the Real Value member. Giving this dimension a name can be quite difficult, as it should be something that helps the users understand what it does – here we've called it Date Tool. It needs no relationship to any measure group at all to work.
Our next task is to overwrite the value returned by each member so that they return the calculations we want. We can do this using a simple SCOPE statement in the MDX Script of the cube:
此代码可让您为所有度量创建 YEAR-TO-DATE 聚合。
SCOPE ([Date Tool].[Calculation].[Year To Date]); THIS = AGGREGATE ( YTD ([Date Order].[Calendar].CurrentMember), [Date Tool].[Calculation].[Real Value]); END SCOPE;