2017-07-28 61 views
0

我有一種情況,我有一個空值進來的列,該值需要被替換爲另一個值。在mdx中替換Null字段

當前MDX

select 
non empty { [measures.[Color count]} on columns 
,non empty { [ColorColor].[Color].[Color].allmembers} 
Dimention properties 
member caption 
,member_unique_name 
on rows 
from [Colors] 

當前結果

Color  Color Count 
null  1 
Red  1 
Blue  1 
Purple 1 
Black  1 

預期的結果

Color  Color Count 
Silver 1 
Red  1 
Blue  1 
Purple 1 
Black  1 

基本上我需要的顏色 「銀子」,以取代空。此外,空值需要在mdx中進行替換,而不是在ssrs中進行替換。

回答

1

使用WITH MEMBER您可以創建一個新項目,併爲其指定任何名稱,並告訴它從NULL項目獲取其值。然後你可以使用EXCEPT函數的第二個參數來隱藏你不想要的項目。

with member [ColorColor].[Color].[Color].[MyNewName] 
AS [ColorColor].[Color].[Color].[null] 
select 
non empty { [measures.[Color count]} on columns 
,non empty { 
[ColorColor].[Color].[Color].[MyNewName], 
EXCEPT({[ColorColor].[Color].[Color].allmembers},{[ColorColor].[Color].[Color].[null]}) 
} 
Dimention properties 
member caption 
,member_unique_name 
on rows 
from [Colors]