【发布时间】:2015-09-08 10:39:04
【问题描述】:
样本数据
我已以以下格式导出 OLAP 多维数据集(测量 [Some Percent] 使用情况为 Average over time):
[Net Weight] [Some Percent]
4 387 2,10%
3 304 1,60%
Grand total: 7 691 1,85% -- Percent is AVG
公式
我需要创建新的计算成员[Modified Percent],其计算方式如下:
[Net Weight].[1] / [Net Weight].[Total] * [Some Percent].[1] +
[Net Weight].[2] / [Net Weight].[Total] * [Some Percent].[2] +
[Net Weight].[n] / [Net Weight].[Total] * [Some Percent].[n] -- can be n rows
带有样本数据的公式
所以我的示例数据将是:
4 387 / 7691 * 2,10 + | 1,20%
3 304 / 7691 * 1,60 | 0,69%
= | 1,89% -- Sum of percent
期望的输出
[Modified Percent] 应返回如下:
[Net Weight] [Some Percent] [Modified Percent]
4 387 2,10% 1,20%
3 304 1,60% 0,69%
Grand total: 7 691 1,85% -- Percent is AVG 1,89%
MDX 脚本
现在我在下面有MDX Script,但[Modified Percent] 返回的值与[Some Percent] 相同
CREATE MEMBER CURRENTCUBE.[Measures].[Modified Percent]
AS ([Measures].[Net Weight] / sum([Vendor Invoice].[Vendor Invoice No].[All],[Measures].[Net Weight])) * [Measures].[Some Percent],
FORMAT_STRING = 'Percent',
NON_EMPTY_BEHAVIOR = { [Net Weight] },
VISIBLE = 1;
也试过这个,但不走运,结果也一样:
CREATE MEMBER CURRENTCUBE.[Measures].[Modified Percent]
AS ([Vendor Invoice].[Vendor Invoice No].CurrentMember,[Measures].[Net Weight]) /
iif(
([Vendor Invoice].[Vendor Invoice No].CurrentMember.Parent,[Measures].[Net Weight]) = 0,
([Vendor Invoice].[Vendor Invoice No].CurrentMember,[Measures].[Net Weight]),
([Vendor Invoice].[Vendor Invoice No].CurrentMember.Parent,[Measures].[Net Weight])
)
* [Measures].[Some Percent],
FORMAT_STRING = 'Percent',
NON_EMPTY_BEHAVIOR = { [Net Weight] },
VISIBLE = 1;
看起来像拆分部分返回 1。你有什么想法如何解决它吗?如果有什么不清楚的地方-问我,我会提供更多细节。
【问题讨论】:
-
您的代码在我看来没问题。如果你用
WITH member...代替create member,结果好吗? -
斯坦尼斯洛瓦斯 - 试试上面的 ^^
-
@SouravA 也许你误解了这个问题伙伴 - 我认为这个问题与“立方体脚本”有关......因此使用
CREATE -
@whytheq 没有。实际上,我想知道 Query Scoped 成员是否工作正常。我必须在 AW 中测试这个。
标签: sql-server ssas mdx olap cube-script