[英]Filtering measure by dimension causes similar behaviour to IgnoreUnrelatedDimensions = True in calculated member
我正在嘗試使用SSAS在SSRS中定義一個計算成員,該成員是根據維值過濾的度量之和。 效果很好,除非我按過濾的維度在瀏覽器中查看計算所得的成員。 不會在期望的位置看到null
值,而是在行上重復總計,類似於在度量值組IgnoreUnrelatedDimensions
設置為True
時發生的情況。
我怎樣才能解決這個問題?
在SSRS的“計算”選項卡上定義的示例計算成員:
AGGREGATE({[Cow].[Hoof Location].[Front]}, [Measures].[Count])
在[Cow].[Hoof Location]
以外的任何地方觀看時,此效果都很好。 但是,從該維度查看時,Count將在各行之間重復。
你可以試試
IIf([Cow].[Hoof Location].CurrentMember IS [Cow].[Hoof Location].[All],
AGGREGATE({[Cow].[Hoof Location].[Front]}, [Measures].[Count]),
NULL
)
可能您必須使“ All
成員的名稱適應其在多維數據集中的名稱。
這是使用所需技巧的MDX計算量度:
我用我的基地,所以請替換[Create Date].[Create Date].[Year].&[2014]
用自己的一套和[Create Date].[Create Date].[Month]
與你的尺寸的水平[Cow]
。 這是標准的“年月日”維度。
CREATE MEMBER CURRENTCUBE.[Measures].[TestAgg]
AS
IIF(
Intersect(
[Create Date].[Create Date].CurrentMember
,Exists(
Descendants(
[Create Date].[Create Date].[Year].&[2014]
,[Create Date].[Create Date].[Month]
,SELF_BEFORE_AFTER
)
)
).Count > 0
,[Measures].[Count]
,IIF(
[Create Date].[Create Date].CurrentMember is [Create Date].[Create Date].[All]
,AGGREGATE(
{[Create Date].[Create Date].[Year].&[2014]}
,[Measures].[Count])
,null
)
),
VISIBLE = 1;
這里是一些解釋:
Descendants
來組織必要的成員集。 Intersect
用於了解尺寸的當前成員是否在此過濾條件下。 IIF
用於顯示其他年份的空白。 IIF
用於總計。 以及有關該度量行為的一些圖片:
如果您希望在2014年的每個級別及其子級上使用相同的值(對於其他級別則為空白),請
AGGREGATE(
{Exists(
Descendants(
[Create Date].[Create Date].[Year].&[2014],
[Create Date].[Create Date].[Month],
AFTER)
)
},
[Measures].[Count]
)
或SUM
。 但是我想這個成員和孩子看起來像IgnoreUnrelatedDimensions=True
,就像您之前所說的那樣。
另一個提示:如果對其他級別進行過濾,則可以使用Descendants
級別和標志參數( AFTER
, BEFORE
, SELF_AND_AFTER
等)進行SELF_AND_AFTER
。本文可以幫助您理解此技術: http : SELF_AND_AFTER
/ 08 / mdx-descendants /
希望這將有助於解決問題。
更新對於最低級別,最好像這樣使用Ascendants
:
CREATE MEMBER CURRENTCUBE.[Measures].[TestAgg2]
AS
IIF(
Intersect(
[Create Date].[Create Date].CurrentMember,
Exists(
Ascendants([Create Date].[Create Date].[Day].&[20140214])
)
).Count > 0,
(
[Create Date].[Create Date].[Day].&[20140214],
[Measures].[Count]
),
IIF(
[Create Date].[Create Date].CurrentMember is [Create Date].[Create Date].[All],
AGGREGATE(
{[Create Date].[Create Date].[Day].&[20140214]},
[Measures].[Count]
),
null
)
),
VISIBLE = 1;
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.