2017-08-31 81 views
0

我無法擺脫下列MDX輸出查詢中的空行。 我正在顯示特定維度的最後12個月收入,其層次結構中有4個級別。 我正在篩選此輸出基於where語句中的其他維度。MDX無法過濾掉空行

我試過NON EMPTY,NonEmpty(),FILTER等,但我無法得到它的工作。

Please look at this image.

WITH 
    MEMBER [Measures].[Member Full Path] AS 
    [Revenuedim].CurrentMember.UniqueName 
    MEMBER [Measures].[Member Ordinal] AS 
    [Revenuedim].CurrentMember.Ordinal 
SELECT 
    NON EMPTY 
    Hierarchize 
    (
     Union 
     (
     CrossJoin 
     (
      [Measures].[BeaconAmount_USD] 
     ,LastPeriods 
      (12 
      ,[Date.YQM].LastChild.LastChild.LastChild 
     ) 
     ) 
     ,CrossJoin 
     (
      { 
      [Measures].[Member Ordinal] 
      ,[Measures].[Member Full Path] 
      } 
     ,[Date.YQM].[2018] 
     ) 
    ) 
    ,POST 
    ) ON COLUMNS 
,NON EMPTY 
    Order 
    (
     ToggleDrillState 
     (
     ToggleDrillState 
     (
      ToggleDrillState 
      (
      ToggleDrillState 
      (
       {[Revenuedim].[All CPs]} 
      ,{} 
      ) 
      ,{} 
     ) 
     ,{} 
     ) 
     ,{} 
    ) 
    ,[Measures].[BeaconAmount_USD] 
    ,DESC 
    ) ON ROWS 
FROM [Revenue_CP] 
WHERE 
    [Revenuedim_SOB].[TCS BPO Chile S.A.]; 
+1

@AliMajedHA請不要加'感謝'一篇文章,[它被認爲是噪音,應該避免](https://meta.stackoverflow.com/a/260778/4244993) – jmattheis

回答

1

你可以嘗試添加一個條件到自定義的措施:

WITH 
    MEMBER [Measures].[Member Full Path] AS 
    [Revenuedim].CurrentMember.UniqueName 
    MEMBER [Measures].[Member Ordinal] AS 
    [Revenuedim].CurrentMember.Ordinal 
... 
... 

所以IIF基於一個元組例如([Revenuedim] .CurrentMember,[Date.YQM] [2018])可能會做它:

WITH 
    MEMBER [Measures].[Member Full Path] AS 
    IIF(
    ([Revenuedim].CurrentMember, [Date.YQM].[2018]) = 0 
    ,NULL 
    ,[Revenuedim].CurrentMember.UniqueName 
    ) 
    MEMBER [Measures].[Member Ordinal] AS 
    IIF(
    ([Revenuedim].CurrentMember, [Date.YQM].[2018]) = 0 
    ,NULL 
    ,[Revenuedim].CurrentMember.Ordinal 
    ) 
... 
... 
+0

不,不幸的是,這是行不通的。相反,它僅在序號列的所有CP級別(Revenuedim的所有級別)上顯示空白,因爲該單元字面上爲0(=常數爲0 ...) – user1186098

+0

但它與事實有關計算出來的度量總是存在的......因爲將它們排除在外,它不會顯示空行。我該如何解決這個問題:(?? – user1186098

0

終於找到我需要的東西......

WITH 
    MEMBER [Date.YQM].[Last12M] AS 
    Aggregate( 
    Tail([Date.YQM].[Month].Members,12)) 

    MEMBER [Measures].[Member Full Path] AS 
    IIF(
    isEmpty ([Revenuedim].CurrentMember * [Date.YQM].[2017] * [Measures].[BeaconAmount_USD] * [Revenuedim_SOB].[TCS BPO Chile S.A.]) 
     ,NULL 
    ,[Revenuedim].CurrentMember.UniqueName 
    ) 
    MEMBER [Measures].[Member Ordinal] AS 
    IIF(
    isEmpty([Revenuedim].CurrentMember * [Date.YQM].[2017] * [Measures].[BeaconAmount_USD] * [Revenuedim_SOB].[TCS BPO Chile S.A.]) 
    ,NULL 
    ,[Revenuedim].CurrentMember.Ordinal 
    ) 

     SELECT 
     NON EMPTY 
     Hierarchize(

     Union(
       Crossjoin([Measures].[BeaconAmount_USD] ,  
       LastPeriods(12,[Date.YQM].lastChild.lastChild.lastChild) 
       ) 
      , 
      Crossjoin({[Measures].[Member Ordinal], [Measures].[Member Full Path]}, [Date.YQM].[Last12M]) 
     ) 
     ,POST) ON COLUMNS, 

     NON EMPTY 
      ORDER(
      TOGGLEDRILLSTATE(
       TOGGLEDRILLSTATE(
        TOGGLEDRILLSTATE(
         TOGGLEDRILLSTATE(
        {[Revenuedim].[All CPs]}, 
       {[Revenuedim].[All CPs]} 
      ) 
      , {} 
     ), {} 
     ), {} 
    ) 
,[Measures].[BeaconAmount_USD], 
DESC) 
ON ROWS from [Revenue_CP] 
where [Revenuedim_SOB].[TCS BPO Chile S.A.] 
+0

blimey - 我的嘗試的一些鼓勵會受到讚賞 - 我的答案當然有幫助? – whytheq

+0

爲什麼你在'IsEmpty'函數內進行交叉連接?交叉連接產生單個元組集 - 所以你可能只是使用元組? – whytheq