MDX格式化数字值为字符串

时间:2016-11-08 18:23:39

标签: ssas mdx

我有这个称为[同比(市场份额)]的指标,客户希望看到:“0.2 ppt”在该领域。数字,一个小数位,附加字符串“ppt”。我如何获得这个?

    CREATE MEMBER CURRENTCUBE.[Measures].[Market Sales % CY] AS NULL, VISIBLE = 1, Display_Folder = 'Calcs';  
SCOPE([Measures].[Market Sales % CY]);  
        This =  (([Measures].[Market Share %],[Version].[Version].&[Actual]));

END SCOPE;  

CREATE MEMBER CURRENTCUBE.[Measures].[Market Sales % PY] AS NULL, VISIBLE = 1, Display_Folder = 'Calcs';  
SCOPE([Measures].[Market Sales % PY]);  
        This = ([Measures].[Market Share %],[Version].[Version].&[Actual PY]); 

END SCOPE;


CREATE MEMBER CURRENTCUBE.[Measures].[YoY ppt (Market Share)] AS NULL, VISIBLE = 1;
SCOPE([Measures].[YoY ppt (Market Share)]);  
        This = CASE WHEN ISEMPTY([Measures].[Market Sales % PY]) OR ISEMPTY([Measures].[Market Sales % CY]) THEN NULL 
ELSE ([Measures].[Market Sales % CY] * 100 - [Measures].[Market Sales % PY] * 100)
END;
    --FORMAT_STRING(This) = "Percent";    
FORMAT_STRING(This) = "Fixed"; -- to be changed to "0.0 ppt"
END SCOPE;  

1 个答案:

答案 0 :(得分:0)

这有用吗?

CREATE MEMBER CURRENTCUBE.[Measures].[YoY ppt (Market Share)] AS NULL
, VISIBLE = 1;

SCOPE([Measures].[YoY ppt (Market Share)]);
This = 
   CASE WHEN ISEMPTY([Measures].[Market Sales % PY]) 
             OR ISEMPTY([Measures].[Market Sales % CY]) THEN NULL 
   ELSE ([Measures].[Market Sales % CY] * 100 - [Measures].[Market Sales % PY] * 100)
   END;
END SCOPE;  

SCOPE([Measures].[YoY ppt (Market Share)]); 
FORMAT_STRING(this) = "0.0 \p\p\t";
END SCOPE;