写等效于作用域分配的计算成员

时间:2018-12-06 20:13:35

标签: ssas mdx

我试图更好地理解范围和计算所得的成员,因此在AdventureWorks数据库中,我进行了以下操作:

我写了这个简单的作用域声明:

SCOPE([Customer].[Customer].[All Customers], [Measures].[Average Rate]);  
        /* This expression sets the value of the Amount measure */  
        THIS = 999;  
END SCOPE;  

等效的计算成员将是这样:

Create Member CurrentCube.[Measures].[My Measure]
 AS 
iif([Customer].[Customer].currentmember IS [Customer].[Customer].[All Customers], 999, [Measures].[Average Rate]);

但是我不确定如何创建与该范围分配等效的计算所得成员:

SCOPE([Customer].[Country].members, [Measures].[Average Rate]);  
        /* This expression sets the value of the Amount measure */  
        THIS = 999;  
END SCOPE; 

实际上,我不确定如何编写iff来检查“客户”维度的当前成员是否是“ [客户]”的成员。[国家/地区]

1 个答案:

答案 0 :(得分:0)

你在这里

///Will Display 999 for any member apart from All


     with Member [Measures].[My Measure]
         AS 
         iif([Customer].[Country].currentmember.Properties ("Member_Value",TYPED)='All Customers',[Measures].[Internet Sales Amount] , 999)

        select {[Measures].[Internet Sales Amount],[Measures].[My Measure]}
         on columns,

        [Customer].[Country].members
        on rows 
        from [Adventure Works]

    ///Will display 999 for any member
        with Member [Measures].[My Measure]
         AS 
         iif([Customer].[Country].currentmember.Properties ("Member_Value",TYPED)='WhatEver', 999, 999)

        select {[Measures].[Internet Sales Amount],[Measures].[My Measure]}
         on columns,

        [Customer].[Country].members
        on rows 
        from [Adventure Works]

//下面的查询有助于检查成员是否属于层次结构 ///////////////////////////////////////////////////// ///////////////////////

//Query checks if a Member is part of a hierarchy
with MEMBER TestIFAValidMember
as 
[Product].[Subcategory].[InvalidMember].UniqueName

MEMBER TestIFAValidMember2
as 
[Product].[Subcategory].[Caps].UniqueName

select {TestIFAValidMember,TestIFAValidMember2}
on columns 
FROM [Adventure Works]

您也可以尝试

WITH MEMBER MEASURES.NotMember AS

IsSibling([Product].[Category].CURRENTMEMBER, [Product].[Category].[Invalid])

MEMBER MEASURES.ISMember AS

IsSibling([Product].[Category].CURRENTMEMBER, [Product].[Category].[Bikes])

SELECT {MEASURES.NotMember,MEASURES.ISMember} ON 0,

[Product].[Category].MEMBERS ON 1

FROM [Adventure Works]