MDX的新手,我一直在努力解决这个问题并需要帮助。
我有一个日期层次结构,我可以计算最新加载季度的案例数,但我正在努力计算百分比。
我的疑问是:
Member [Measures].[Latest Available Full Quarter Percentage]
As
(
ClosingPeriod
(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Count]
)
Select
[Measures].[Latest Available Full Quarter Percentage] On Columns
,[Things].[Category].Members On Rows
From [Stuff]
输出如下:
Latest Available Full Quarter Percentage
All 73
Thing1 5
Thing2 12
Thing3 (null)
Thing4 1
Thing5 32
Thing6 9
Thing7 (null)
Thing8 13
Thing9 5
Thing10 6
我想要做的是为每行产生一个百分比,除数为73,输出看起来如此:
Latest Available Full Quarter Percentage
All 100%
Thing1 6.8%
Thing2 16.4%
Thing3 0%
Thing4 1.4%
Thing5 43.8%
Thing6 12.3%
Thing7 0%
Thing8 17.8%
Thing9 6.8%
Thing10 8.2%
我无法弄清楚如何使每个行的73数字静态,因此可以执行百分比计算。
任何人都可以协助并指出我出错的地方吗?
编辑:
我想解决方案与此相同:
Member [Measures].[Latest Available Full Quarter Percentage]
As
(
ClosingPeriod
(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Count]
)
/
(
ClosingPeriod
(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Count]
).Parent
Select
[Measures].[Latest Available Full Quarter Percentage] On Columns
,[Things].[Category].Members On Rows
From [Stuff]
这不行,但我觉得它沿着这些方向
关键是计算需要与成员扩展保持一致。
编辑第2部分:
对于指定维度已经考虑过这个问题,我们正在考虑:
Member [Measures].[Latest Available Full Quarter Percentage]
As
(
ClosingPeriod
(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Distinct Count]
)
/
(
[Complaints Category].[Category].[All]
,
(
ClosingPeriod
(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Distinct Count]
)
)
,Format_String = "Percent"
Select
[Measures].[Latest Available Full Quarter Percentage] On Columns
,[Things].[Category].Members On Rows
From [Stuff]
这给了我:
Latest Available Full Quarter Percentage
All 100%
Thing1 6.85%
Thing2 16.44%
Thing3 (null)
Thing4 1.37%
Thing5 43.84%
Thing6 12.33%
Thing7 (null)
Thing8 17.81%
Thing9 6.85%
Thing10 8.22%
然而,接下来的挑战是让它在不同维度上发挥作用
同时有任何建议,很乐意接受
答案 0 :(得分:0)
我可能会误解,但您可以在计算中进行正常划分 - 使用运算符/
或通过函数DIVIDE
:
WITH
MEMBER [Measures].[cnt2]
(
ClosingPeriod(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Count]
,[Things].[Category].[All] //<< added to this tuple to reference All member
)
MEMBER [Measures].[cnt] AS
COUNT([Things].[Category].Members)
MEMBER [Measures].[Latest Available Full Quarter Percentage] AS
DIVIDE(
(
ClosingPeriod(
[Dates].[Quarter].[Quarter]
,[Dates].[Quarter].DefaultMember
)
,[Measures].[Count]
)
, [Measures].[cnt2] //<< changed to cnt2
), FORMAT_STRING="##.00%"
SELECT
[Measures].[Latest Available Full Quarter Percentage] ON COLUMNS
,[Things].[Category].Members ON ROWS
FROM [Stuff];