2016-02-28 117 views
0

我有一个MDX查询返回如下结果:筛选器mdx查询结果

Customer |存储|销售

A | Store_1 | 123.45

A | Store_2 | 234.56

B | Store_2 | 345.67

B | Store_3 | 456.78

C | Store_1 | 543.21

C | Store_3 | 654.32

如何查询应该有结果,显示每个客户只有一排只有第一家店:

A | Store_1 | 123.45

B | Store_2 | 345.67

C | Store_1 | 543.21

更新: 实际查询

SELECT 

    [Measures].[Sales] ON COLUMNS, 

    NON EMPTY(
    [Customers].[User].[User], [Stores].[Store].[Store] 
) ON ROWS 

FROM SALES 
+0

请添加您的MDX脚本的问题 – whytheq

回答

0

如果我运行此:

SELECT 
    [Measures].[Internet Sales Amount] ON 0 
, 
    [Product].[Category].[Category] 
    * 
    [Customer].[Customer Geography].[Country] ON 1 
FROM [Adventure Works]; 

我得到如下:

enter image description here

如果我只想first为每个类别我需要做的是这样的:

WITH 
    SET [cats] AS 
    [Product].[Category].[Category] 
    SET [cats_country] AS 
    Generate 
    (
     [cats] AS S 
    , 
     S.Current 
     * 
     Head(NonEmpty([Customer].[Customer Geography].[Country],S.Current)) 
    ) 
SELECT 
    [Measures].[Internet Sales Amount] ON 0 
,[cats_country] ON 1 
FROM [Adventure Works]; 

结果在此:

enter image description here

+0

谢谢。它适用于我的目的。表现不是很好,但会尝试找到改善的地方。有任何想法吗? – greyzet