过滤mdx查询结果
Filter mdx query result
我有一个 MDX 查询 return 结果如下:
客户 |店铺 |销售额
一个 | Store_1 | 123.45
一个 | Store_2 | 234.56
B | Store_2 | 345.67
B | Store_3 | 456.78
C | Store_1 | 543.21
C | Store_3 | 654.32
查询应该如何让结果只显示第一家商店的每个客户一行:
一个 | 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
如果我运行这个:
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];
结果:
我有一个 MDX 查询 return 结果如下:
客户 |店铺 |销售额
一个 | Store_1 | 123.45
一个 | Store_2 | 234.56
B | Store_2 | 345.67
B | Store_3 | 456.78
C | Store_1 | 543.21
C | Store_3 | 654.32
查询应该如何让结果只显示第一家商店的每个客户一行:
一个 | 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
如果我运行这个:
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];
结果: