2016-04-18 42 views
1

我有SSRS中的一個財務報表,它運行了MDX查詢。報告運行後,導出到Excel,然後加載到SAP等財務系統中。SSRS/MDX - 額外的反向費用行

我需要包含一個「反轉」行,對於屬於某個類別的費用。例如(下面)對於任何具有「產品運費」的「類型」的商品,我還希望包含具有負值的額外行,從而實質上扭轉報告中的費用。

此:

| Charge   | Account | Type   | Invoice | GST | 
|------------------|---------|-----------------|---------|-----| 
| Apple   | 123  | Product   | $100 | $10 | 
| Banana   | 123  | Product   | $200 | $20 | 
| Orange   | 456  | Product   | $150 | $15 | 
| Orange (Freight) | 456  | Product Freight | $50  | 0 | 

會變成這樣:

| Charge   | Account | Type   | Invoice | GST | 
|------------------|---------|-----------------|---------|-----| 
| Apple   | 123  | Product   | $100 | $10 | 
| Banana   | 123  | Product   | $200 | $20 | 
| Orange   | 456  | Product   | $150 | $15 | 
| Orange   | 456  | Product Freight | $50  | 0 | 
| Orange (Freight) | 456  | Product Freight | ($50) | 0 | 

UPDATE

這是MDX查詢的一個簡單的版本:

WITH MEMBER measures.[Charge] AS 
    [Charge].[Charge All].CurrentMember .member_name 

MEMBER measures.[Account] AS 
    [Account].[Account All].CurrentMember .member_name 

MEMBER measures.[ChargeType] AS 
    [Charge Type].[Charge Type Group].CurrentMember .member_name 

MEMBER measures.[GST] AS 
    ([Charge Type].[Charge Type Class].&[GST], measures.[value]) 

MEMBER measures.[InvExcGST] AS 
    measures.[Value] - measures.[GST] 

SELECT 
{ 
measures.[Charge], 
measures.[Account], 
measures.[ChargeType], 
measures.[InvExcGST], 
measures.[GST] 
} 
ON 0, 

NON EMPTY 
[Charge].[Charge All].[All].Children * 
[Account].[Account all].[all].Children * 
[Charge Type].[Charge Type Group].[All].Children 
HAVING measures.[Value] <> 0 
ON 1 

FROM CubeName 
+0

您可以添加當前的mdx嗎? – whytheq

+1

我用MDX查詢更新了這個問題 – TaylorN

回答

1

我認爲以下將複製目標行 - 仍然不確定如何添加否定措施:

WITH 
MEMBER [measures].[Charge] AS 
    [Charge].[Charge All].CurrentMember.member_name 
MEMBER [measures].[Account] AS 
    [Account].[Account All].CurrentMember.member_name 
MEMBER [measures].[ChargeType] AS 
    [Charge Type].[Charge Type Group].CurrentMember.member_name 
MEMBER [measures].[GST] AS 
    ( 
    [Charge Type].[Charge Type Class].&[GST] 
    , [measures].[value] 
) 
MEMBER [measures].[InvExcGST] AS 
    [measures].[Value] - [measures].[GST] 
SET [AllCombos] AS 
    NonEmpty(
    [Charge].[Charge All].[All].Children 
    *[Account].[Account all].[all].Children 
    *[Charge Type].[Charge Type Group].[All].Children 
    ,[measures].[Value] 
) 
SET [AllCombosFilter] AS 
    FILTER(
    [AllCombos] AS S 
    ,S.ITEM(0).ITEM(2) 
     IS [Charge Type].[Charge Type Group].[Charge Type Group].&[Product Freight] 
) 
SELECT 
    { 
    [measures].[Charge], 
    [measures].[Account], 
    [measures].[ChargeType], 
    [measures].[InvExcGST], 
    [measures].[GST] 
    } 
    ON 0, 
NON EMPTY 
    UNION([AllCombos], [AllCombosFilter], ALL) ON 1 
FROM CubeName;