MDX 表达式错误

Error with MDX expression

我有以下表达式 MDX :

isnull([Measures].[Available Hours],0)

处理多维数据集后,我在报告中遇到以下错误:

No appropriate overload function was found for the stored procedure .The parameters are incorrect .MdxScript Execution of the managed stored procedure isnull failed with the following error :Microsoft AnalysisServices AdomdServer AdomdException

如何解决错误?

isnull 不是 mdx 函数。

要在 mdx 中测试 null,请尝试使用 iif

 iif(  
  [Measures].[Available Hours] = 0,
  0,
  [Measures].[Available Hours]
 )

当我们查找 0 时看起来有点奇怪,如果是 0 则将其更改为 0!!

但这里有一个例子:

WITH 
  MEMBER [Measures].[Internet Sales Amount 2] AS 
    IIF
    (
      [Measures].[Internet Sales Amount] = 0
     ,0
     ,[Measures].[Internet Sales Amount]
    ) 
SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,[Measures].[Internet Sales Amount 2]
  } ON 0
 ,
    [Customer].[Customer Geography].[Country].MEMBERS
  * 
    [Product].[Category].MEMBERS ON 1
FROM [Adventure Works];

事情是这样的:


编辑

@MarcPolizzi 的替代方案做同样的事情,他的代码更紧凑:

WITH 
  MEMBER [Measures].[Internet Sales Amount 2] AS 
    IIF
    (
      [Measures].[Internet Sales Amount] = 0
     ,0
     ,[Measures].[Internet Sales Amount]
    ) 
  MEMBER [Measures].[Internet Sales Amount 3] AS 
    CoalesceEmpty
    (
      [Measures].[Internet Sales Amount]
     ,0
    ) 
SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,[Measures].[Internet Sales Amount 2]
   ,[Measures].[Internet Sales Amount 3]
  } ON 0
 ,
    [Customer].[Customer Geography].[Country].MEMBERS
  * 
    [Product].[Category].MEMBERS ON 1
FROM [Adventure Works];

您可以使用 CoalesceEmpty 函数来替换 null/empty 值。要将它们替换为 0 值,您可以执行以下操作:

CoalesceEmpty([Measures].[Available Hours], 0)

希望对您有所帮助。