簡體   English   中英

過濾mdx查詢結果

[英]Filter mdx query result

我有一個MDX查詢,返回的結果如下:

客戶| 店鋪| 營業額

A | 商店_1 | 123.45

A | 商店_2 | 234.56

B | 商店_2 | 345.67

B | Store_3 | 456.78

C | 商店_1 | 543.21

C | Store_3 | 654.32

查詢的外觀應如何使結果顯示每個客戶僅在第一家商店中僅顯示一行:

A | 商店_1 | 123.45

B | 商店_2 | 345.67

C | 商店_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];

結果:

在此處輸入圖片說明

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM