2016-08-04 102 views
1

我需要从集合中删除所有2个月。此代码返回所有日期范围,但不包括2个月。从日期范围除特定日期以外的MDX查询

SELECT 
    {[Measures].[In]} ON COLUMNS, 
    EXCEPT([Date].[2014].[1] : [Date].[2016].[2], [Date].[Month].[2]) ON ROWS 
FROM [Shop hourly] 

为whytheq打印屏幕 enter image description here

我的决定基于whytheq answear。我为所有类型的日期创建了一个维度,除了它们。例如:

SELECT {[Measures].[In sum]} ON COLUMNS, 
    NON EMPTY 
     {[Shop].[11], [Shop].[22], [Shop].[33]} * 
     Except([Quarter].Children, [Quarter].[2]) * 
     [Month].Children ON ROWS 
FROM [Shop hourly] 
WHERE 
    ([Date].[2013].[1].[1] : [Date].[2016].[1].[1]) * 
    Except([Year].Children, [Year].[2014]) 

enter image description here

+0

所以你想要删除{2014年2月,2015年2月,2016年2月}? – whytheq

+0

是的,这是我想要的 – Nodon

+0

- 我回答了下面的问题 – whytheq

回答

1

AdventureWorks我可以做到以下几点:

SELECT 
    [Measures].[Internet Sales Amount] ON 0 
,NON EMPTY 
    Except 
    (
     [Date].[Calendar].[Month].&[2005]&[7] 
     : 
     [Date].[Calendar].[Month].&[2008]&[7] 
    ,Exists 
     (
     [Date].[Calendar].[Month].MEMBERS 
     ,[Date].[Calendar Quarter of Year].&[CY Q3] 
    ) 
    ) ON 1 
FROM [Adventure Works]; 

所以调整上述对多维数据集可能看起来如下:

SELECT 
    {[Measures].[In]} ON COLUMNS 
,Except 
    (
    [Date].[2014].[1] : [Date].[2016].[2] 
    ,Exists 
    (
     [Date].MEMBERS 
    ,[Date].[Month].[2] 
    ) 
) ON ROWS 
FROM [Shop hourly]; 
+0

Mondrian更改[日期]。[月]。[2]到[日期]。[2012]。[2]我不知道它为什么这样做。 – Nodon

+0

您需要添加[[Date]'维度结构的屏幕印记,以便我了解发生了什么。 – whytheq

+0

我添加了屏幕。 – Nodon