获取MDX中日期范围的上次销售日期和销售额

时间:2012-11-15 17:10:12

标签: mdx

我需要使用SalesAmount获取LastSalesDate作为日期范围。但是以下MDX未按日期范围过滤。其他数据还可以。

WITH MEMBER [Measures].[MaxSaleDate] 
    AS 
        TAIL(
            FILTER(
                [Date—Date].[Date].MEMBERS, 
                NOT ISEMPTY([Measures].[Sales])
            )
        ).ITEM(0).NAME

SELECT { [Measures].[MaxSaleDate], NONEMPTY([Measures].[Sales]) } ON COLUMNS,
       { [Store—Store].[Store].MEMBERS * [Store-NoOfDaysSales].[NoOfDays].MEMBERS } ON ROWS
FROM ( SELECT (  
           [Date—Date].[All Date—Date].[2012-10-14 00:00:00.000] :  
           [Date—Date].[All Date—Date].[2012-11-14 00:00:00.000]
       ) ON COLUMNS 
       FROM [Sales])

感谢。非常感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

您的过滤器语句将选择日期维度中的所有日期而不是过滤器。你的地方也有一个不必要的子立方体。

WITH

MEMBER [Measures].[MaxSaleDate] AS
TAIL(FILTER([Date—Date].[All Date—Date].[2012-10-14 00:00:00.000] :
            [Date—Date].[All Date—Date].[2012-11-14 00:00:00.000],
            NOT ISEMPTY([Measures].[Sales])
            )
      ).ITEM(0).Name

SELECT { [Measures].[MaxSaleDate], NONEMPTY([Measures].[Sales]) } ON COLUMNS,
{ [Store—Store].[Store].MEMBERS * [Store-NoOfDaysSales].[NoOfDays].MEMBERS } ON ROWS
FROM [Sales]
WHERE [Date—Date].[All Date—Date].[2012-10-14 00:00:00.000] :
      [Date—Date].[All Date—Date].[2012-11-14 00:00:00.000]