2017-03-15 85 views
0

--Total FEB-2008 SalesAmount兩個MDX:除了我需要的總銷售金額中某一年

SELECT 
{[Measures].[Internet Sales Amount]} ON 0, 
{[Date].[Calendar].[Month].&[2008]&[2]} ON 1 
FROM [Adventure Works] 
WHERE [Date].[Calendar Year].&[2008] 

- $ 47,868.54(對於FEB月29日SalesAmount兩個)

SELECT 
{[Measures].[Internet Sales Amount]} ON 0, 
{[Date].[Calendar].[Date].&[20080229]} ON 1 
FROM [Adventure Works] 
WHERE [Date].[Calendar Year].&[2008] 

--Here如何排除FEB月29日SalesAmount兩個在該年

SELECT 
    {[Measures].[Internet Sales Amount]} ON 0, 
EXCEPT(

    [Date].[Calendar].[Month], 
    {[Date].[Calendar].[Date].&[20080229]} 
) 
    ON 1 
FROM [Adventure Works] 
WHERE [Date].[Calendar Year].&[2008] 

enter image description here

回答

1

也許這:

SELECT 
    [Measures].[Internet Sales Amount] ON 0 
FROM [Adventure Works] 
WHERE 
    EXCEPT(
    DESCENDANTS(
     [Date].[Calendar].[Year].&[2008], 
     [Date].[Calendar].[Date] 
    ), 
    [Date].[Calendar].[Date].&[20080229] 
); 

或者這樣:

WITH 
MEMBER [Date].[Calendar].[All].[2008minus29feb] AS 
AGGREGATE(
    EXCEPT(
    [Date].[Calendar].[Date].MEMBERS, 
    [Date].[Calendar].[Date].&[20080229]} 
) 
) 
SELECT 
    [Measures].[Internet Sales Amount] ON 0, 
    [Date].[Calendar].[All].[2008minus29feb] ON 1 
FROM 
    (
    SELECT [Date].[Calendar Year].&[2008] ON 0 
    FROM [Adventure Works] 
); 

該做的:

SELECT 
    [Measures].[Internet Sales Amount] ON 0 
,[Date].[Calendar].[Month] ON 1 
FROM 
(
    SELECT 
    Except 
    (
     Descendants 
     (
     [Date].[Calendar].[Calendar Year].&[2008] 
     ,[Date].[Calendar].[Date] 
    ) 
    ,[Date].[Calendar].[Date].&[20080229] 
    ) ON 0 
    FROM [Adventure Works] 
); 

結果:

enter image description here

+0

嗨,謝謝你回覆,但結果不匹配,請你看看附帶的屏幕截圖。 – Yugandhar

+0

@Yugandhar ok - 截圖很棒我現在明白要求 – whytheq

+0

@Yandandhar - 使用子選擇我們可以做到 - 看我的編輯 – whytheq