2014-10-18 25 views
0

我必須將兩個mdx查詢結果合併到一個集合中。如何合併兩個mdx查詢當我使用了相同的維度和相同的度量

查詢#1:

SELECT 
     {[Measures].[Internet Sales Amount]} ON COLUMNS, 
     {[Product].[Category].&[4], 
     [Product].[Category].&[1]} ON ROWS 
FROM [Adventure Works]; 

輸出是:

   Internet Sales Amount 
Accessories  $700,759.96 
Bikes   $28,318,144.65 

查詢#2:

SELECT 
     {[Measures].[Internet Sales Amount]} ON COLUMNS, 
     {[Product].[Category].&[3]} ON ROWS 
FROM [Adventure Works] 
where [Geography].[State-Province].&[WA]&[US] 

輸出是:

   Internet Sales Amount 
Clothing $339,772.61 

我想過濾僅適用於「服裝」類別的區域,但不適用於其他類別。

但我想結果在一起。如何結合這兩個結果集?

最終輸出應該是:

 Internet Sales Amount 
Accessories $700,759.96 
Bikes  $28,318,144.65 
Clothing $339,772.61 

回答

1

這似乎工作:

WITH 
    MEMBER [Product].[Category].[Clothing excl WA_US] AS 
    (
     [Product].[Category].&[3] 
    ,[Geography].[State-Province].&[WA]&[US] 
    ) 
SELECT 
    {[Measures].[Internet Sales Amount]} ON COLUMNS 
,{ 
    [Product].[Category].&[4] 
    ,[Product].[Category].&[1] 
    ,[Product].[Category].[Clothing excl WA_US] 
    } ON ROWS 
FROM [Adventure Works]; 

懷疑這個執行得更好:

SELECT 
    {[Measures].[Internet Sales Amount]} ON COLUMNS 
,{ 
    [Product].[Category].&[4] 
    ,[Product].[Category].&[1] 
    ,Exists 
    (
     [Product].[Category].&[3] 
    ,[Geography].[State-Province].&[WA]&[US] 
    ) 
    } ON ROWS 
FROM [Adventure Works]; 
+0

感謝你非常多的解決方案。 – Roshan 2014-10-20 15:11:11

相關問題