使用CDate和DateDiff的Mondrian MDX错误

时间:2015-02-03 14:04:17

标签: mdx datediff mondrian

下面怎么解决问题?

错误:mondrian.olap.fun.MondrianEvaluationException:mondrian.olap.InvalidArgumentException:Mondrian错误:参数无效。必须正确格式化CDate函数的表达式参数

我的MDX请求:

WITH
MEMBER 
    [Measures].[diff] as 'datediff("d",CDate([TimeDim.TimeHir].CurrentMember.Name),now())'
....

2 个答案:

答案 0 :(得分:1)

您是否尝试过其他会员资产:

WITH
MEMBER [Measures].[diff] as 
'datediff("d",CDate([TimeDim.TimeHir].CurrentMember.MEMBER_VALUE),now())'

WITH
MEMBER [Measures].[diff] as
 'datediff("d",CDate([TimeDim.TimeHir].CurrentMember.MEMBER_key),now())'

WITH
MEMBER [Measures].[diff] as 
 'datediff("d",CDate([TimeDim.TimeHir].CURRENTMEMBER.Properties('Key0', Typed)),now())'

修改

这个对我有用AdvWks

WITH

MEMBER [Measures].[Date_MEMBER_VALUE] as 
  [Date].[Calendar].CurrentMember.MEMBER_VALUE
MEMBER [Measures].[Diff_MEMBER_VALUE] as 
  datediff("D",CDate([Measures].[Date_MEMBER_VALUE]),now())

SELECT
{
[Measures].[Date_MEMBER_VALUE]
,[Measures].[Diff_MEMBER_VALUE]
} 
ON 0,
tail([Date].[Calendar].[Date],12) ON 1
FROM [Adventure Works];

编辑

从这里看起来似乎.MEMBER_VALUE在Mondrian中不存在,所以请尝试使用上面的代码而不只是.VALUEhttp://mondrian.pentaho.com/documentation/mdx.php

答案 1 :(得分:-1)

您可以使用DateSerial函数将您的值转换为CDate

接受的日期时间格式