我有一个简单的 olap 多维数据集 - 一组度量和一些乏味的维度。
我添加了一项计算,以根据总销售额衡量得出“占总销售额的百分比”。这个计算的代码是:
([Dim Stores].[Store Name].CurrentMember, [Measures].[Gross Sales])
/
([Dim Stores].[Store Name].Parent, [Measures].[Gross Sales])
这有效。
在商店维度中,有一个称为“按州”的层次结构,其中包含商店。
请教两个问题:
1. 知道为什么当我使用“按州”层次结构时计算不起作用,即按下一个级别分组的相同计算?
蒂亚!
最佳答案
在四处寻找时,我在“计算工具”中找到了一个模板,名为“总百分比”。使用它,我将我的计算转换为:
Case
// Test to avoid division by zero.
When IsEmpty
(
[Measures].[Gross Sales]
)
Then Null
Else ( [Dim Stores].[By State].CurrentMember, [Measures].[Gross Sales] )
/
(
// The Root function returns the (All) value for the target dimension.
Root
(
[Dim Stores]
),
[Measures].[Gross Sales]
)
End
有效!
关于SSAS:占总数的百分比不在层次结构中工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16641900/