MDX中IIF功能的错误结果

时间:2016-06-13 13:17:17

标签: mdx olap-cube iif-function

我写了一个如下所述的查询:

WITH 
  SET [kpi_study] AS 
    {[study].[study].[BHC June12]} 
  SET [geographic] AS 
    {[territory.market_hierarchy].[state].[HP]} 
  SET [brand] AS 
    {[brand.brand_hierarchy].[brand].[Gold Flake (Unspecified)]} 
  SET [edu12] AS 
    IIF
    (
      'All' = 'All'
     ,[education].[education].MEMBERS
     ,[education].[education].[All]
    ) 
SELECT 
  NON EMPTY 
    {[Measures].[tom]} ON COLUMNS
FROM [funnel_analysis]
WHERE 
  {[kpi_study]*[geographic]*[brand]};

结果:汤姆:4.19

而不是全部,如果我通过( SSC / HSC ),任何其他值总是得到相同的值。可以帮助我,我做错了。这意味着IIF功能不正常。

1 个答案:

答案 0 :(得分:0)

您有以下内容:

 SET [edu12] AS 
    IIF
    (
      'All' = 'All'
     ,[education].[education].MEMBERS
     ,[education].[education].[All]
    ) 

所以我猜测All是占位符?! - 你说当你改变其中一个时没有任何事情发生。

这是因为在您的选择中,您实际上并未使用名为SET的{​​{1}},为什么会发生任何变化?

[edu12]

SELECT NON EMPTY {[Measures].[tom]} ON COLUMNS FROM [funnel_analysis] WHERE {[kpi_study]*[geographic]*[brand]}; 应该在行上吗?