我有一个返回结果的MDX查询:
客户|商店|销售
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 :(得分:0)
如果我这样做:
SELECT
[Measures].[Internet Sales Amount] ON 0
,
[Product].[Category].[Category]
*
[Customer].[Customer Geography].[Country] ON 1
FROM [Adventure Works];
我得到以下内容:
如果我只想要每个类别的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];
结果如下: