[英]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.