2016-04-18 43 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;