【问题标题】:Pentaho Mondrian- Hide a dimension value from a rolePentaho Mondrian - 隐藏角色的维度值
【发布时间】:2016-07-13 08:49:40
【问题描述】:

我正在使用 Pentaho Mondrian 构建一个具有“国家”和“参考”维度的计费立方体。 对于我的角色之一,我只想显示国家等于“巴西”时的参考值。如果不是巴西,reference 应该为 null。

它是怎样的: http://i.stack.imgur.com/yipPJ.png

应该如何: http://i.stack.imgur.com/PoF2w.png

我该怎么做?

我尝试在 CASE WHEN 中使用计算成员,但它不起作用。 我应该改用 IIF 吗?

我对此进行了编码,但它也不起作用:

WITH 
  MEMBER [dim_reference.Reference].[reference].Members AS 
    IIF
    (
      [dim_country.country].[country].CurrentMember = 'Brazil'
     ,[dim_reference.Reference].[reference].MEMBERS
     ,''
    ) 
SELECT 
  NON EMPTY 
    {Hierarchize({[dim_country.country].[country].MEMBERS})} ON COLUMNS
 ,NON EMPTY 
    Order
    (
      {
        Hierarchize({[dim_reference.Reference].[reference].MEMBERS})
      }
     ,[dim_reference.Reference].CurrentMember.Name
     ,BASC
    ) ON ROWS
FROM [billing_entry];

有人知道怎么做吗?

【问题讨论】:

    标签: mdx pentaho mondrian case-when iif-function


    【解决方案1】:

    几点建议:

    1

    因此,如果要检查成员是否相等,则需要使用 IS 运算符。

    而不是这样:

    [dim_country.country].[country].CurrentMember = 'Brazil'
    

    您使用以下内容 - 您可能需要使用您的巴西成员的确切全名修改 RHS:

    [dim_country.country].[country].CurrentMember 
           IS [dim_country.country].[country].[country].[Brazil]
    

    2

    您应该使用NULL,而不是使用''

    而不是这样:

    IIF(
          <condition>
         ,<if condition true>
         ,''
        )
    

    你应该使用这个:

    IIF(
          <condition>
         ,<if condition true>
         ,NULL
        )
    

    3

    如果可能的话,使用 IIF 而不是 CASE 是正确的 - IIF 通常性能更好。


    从您的屏幕截图中,我认为您需要国家 ON ROWS 而不是 ON COLUMNS

    SELECT 
      NON EMPTY 
        {} ON COLUMNS
     ,NON EMPTY 
        [dim_country.country].[country].MEMBERS ON ROWS
    FROM [billing_entry];
    

    现在使用SSAS 对抗AdvWrks 立方体我可以这样做:

    WITH 
      MEMBER [Measures].[X] AS 
        IIF
        (
            [Customer].[Customer Geography].CurrentMember
          IS 
            [Customer].[Customer Geography].[Country].&[Australia]
         ,[Product].[Product Categories].CurrentMember.Name
         ,null
        ) 
      SET [s] AS 
          [Customer].[Customer Geography].[Country]
        * 
          [Product].[Product Categories].[category] 
      MEMBER [Product].[Product Categories].[All].[calc] AS 
        [Product].[Product Categories].CurrentMember.Name 
    SELECT 
      {[Measures].[X]} ON 0
     ,[s] ON 1
    FROM [Adventure Works];
    

    结果如下:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-23
      • 2016-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多