2017-10-20 88 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