簡體   English   中英

按維篩選度量值會導致與計算所得成員中的IgnoreUnrelatedDimensions = True相似的行為

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

這里是一些解釋:

  1. 我使用Descendants來組織必要的成員集。
  2. Intersect用於了解尺寸的當前成員是否在此過濾條件下。
  3. 然后,第一個IIF用於顯示其他年份的空白。
  4. 最后一個IIF用於總計。

以及有關該度量行為的一些圖片:

天

月數

年份

如果您希望在2014年的每個級別及其子級上使用相同的值(對於其他級別則為空白),請

AGGREGATE(
    {Exists(
        Descendants(
            [Create Date].[Create Date].[Year].&[2014],
            [Create Date].[Create Date].[Month],
            AFTER)
        )
    },
    [Measures].[Count]
)

SUM 但是我想這個成員和孩子看起來像IgnoreUnrelatedDimensions=True ,就像您之前所說的那樣。

另一個提示:如果對其他級別進行過濾,則可以使用Descendants級別和標志參數( AFTERBEFORESELF_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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM