2017-10-20 142 views
0

,我需要每个季度我坚持用MDX查询

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]; 

的第一个月的销售额有了上述IM每个月得到,但我只需要第一个月。我如何过滤?

+0

您可以只列出你在设置需要几个月 - 像一月,四月,七月,Octomber。另一种解决方案是在集合中写入一个CASE,包括一些数学,以查看它是否分为4);) –

回答

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