SSRS / MDX - 逆转费用的额外行

时间:2016-04-18 07:07:43

标签: excel reporting-services mdx financial

我在SSRS中有一个运行MDX查询的财务报告。运行报告,导出到Excel,然后加载到金融系统,如SAP。

对于属于特定类别的费用,我需要包含“反转”行。例如(下面)对于“类型”为“产品运费”的任何东西,我还想包括一个带有NEGATIVE值的EXTRA行,基本上会反转报告中的费用。

此:

| 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   |

更新

这是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

1 个答案:

答案 0 :(得分: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;