我坚持使用MDX查询

时间:2017-10-20 20:36:01

标签: ssas mdx olap

我需要每季度第一个月的销售额

WITH SET [FIRSTMONTHOFQTR] AS

DESCENDANTS(
        DESCENDANTS(
            [Date].[Calendar].CURRENTMEMBER,
            [Date].[Calendar].[Calendar Quarter]
            ),
            [Date].[Calendar].[Month]
        )

SELECT {
    [Measures].[Sales Amount]
} ON COLUMNS,
{   

[FIRSTMONTHOFQTR]

} ON ROWS
FROM [Adventure Works];

以上我每个月都会得到,但我只需要第一个月。我怎么过滤那个?

1 个答案:

答案 0 :(得分:0)

这是一种方法:

WITH 
  SET [Qtrs] AS 
    [Date].[Calendar].[Calendar Quarter] 
  SET [FIRSTMONTHOFQTR] AS 
    Generate
    (
      [Qtrs] AS s
     ,Head(Descendants(s.CurrentMember,[Date].[Calendar].[Month]))
    ) 
SELECT 
  {[Measures].[Sales Amount]} ON COLUMNS
 ,[FIRSTMONTHOFQTR] ON ROWS
FROM [Adventure Works];

返回以下内容:

enter image description here