Ssrs 2008 从MDX中的日期参数获取月份

Ssrs 2008 从MDX中的日期参数获取月份,ssrs-2008,mdx,Ssrs 2008,Mdx,我目前正在使用Reporting Services(和MDX语言)构建报告。 由于一个参数,我得到了一个日期: MEMBER [Measures].[retail sales amount] AS ( STRTOMEMBER(@TimecalendarTimecalendarmonthhierarchy) , [Measures].[Retail sales amount invoiced including tax]) STRTOMEMBER(@TimecalendarTimecalenda

我目前正在使用Reporting Services(和MDX语言)构建报告。 由于一个参数,我得到了一个日期:

MEMBER [Measures].[retail sales amount] AS (
STRTOMEMBER(@TimecalendarTimecalendarmonthhierarchy)
, [Measures].[Retail sales amount invoiced including tax])
STRTOMEMBER(@TimecalendarTimecalendarmonthhierarchy)可能类似于[Time calendar]。[Time calendar-month hierarchy]。[Time calendar-month]。[Time calendar-date]。&[2011-03-18T00:00:00]

我只想得到这个参数的月份。当我使用:

MTD([Time calendar].[Time calendar month hierarchy].[Time calendar date].&[2011-03-18T00:00:00]
, [Measures].[Retail sales amount invoiced including tax])
它工作得很好,但对我来说不是这样

MTD(STRTOMEMBER(@TimecalendarTimecalendarmonthhierarchy)
, [Measures].[Retail sales amount invoiced including tax])
尝试:

如果不起作用,结果是什么:

STRTOMEMBER(@TimecalendarTimecalendarmonthhierarchy).name

MTD将为您提供从当月第一个日期到指定日期的一组日期。如果要获取月份,可以使用祖先父项。若月份在您的层次结构中直接高于日期,则家长将工作。当你想到前几个月时,SUM(MTD(date),measure)(date.parent,measure)之间的差异是显而易见的-如果你去的是过去的一个月,MTD将给你部分结果,而不是该月成员本身(对于该月最后一天以外的日期)

strotmember本质上是将字符串转换为MDX中的成员表达式。写作与写作(功能上)没有区别:

([Time].[Month].&[201001], [Measures].[SomeMeasure])

当您执行非工作表达式进行调试时,如果您想知道错误到底是什么,那将非常有趣

如果您只想获得该度量的月金额,您应该写:

(StrToMember(@param).Parent, [Measures].[Retail sales amount...])
或者(如果中间有更多级别):

(祖先(StrToMember(@param),
[时间日历].[].],
[措施][零售额…])
另外,当使用MTD时,您要写入:

SUM(MTD(<date member>), [Measure].[Some Measure])
SUM(MTD(),[Measure].[Some Measure])
而不是

MTD(<date member>, [Measure].[Some Measure])
MTD(,[Measure].[Some Measure])

查看一下

谢谢您的回答。您的解决方案不起作用,我不知道如何在查询中使用*.name.*.name,请更改度量值并检查结果。不起作用,为什么?
(Ancestor(StrToMember(@param), 
          [Time calendar].[<hierarchy>].[<month level>]), 
 [Measures].[Retail sales amount...])
SUM(MTD(<date member>), [Measure].[Some Measure])
MTD(<date member>, [Measure].[Some Measure])