SSRS / MDX - 逆转费用的额外行
SSRS / MDX - Extra row for reversal charge
我在 SSRS 中有一份财务报告,运行不符合 MDX 查询。报告 运行,导出到 Excel,然后加载到财务系统,如 SAP。
我需要为属于特定类别的费用添加 "reversal" 行。例如(下图)对于 "Type" 为 "Product Freight" 的任何内容,我还想包含一个 EXTRA 行,该行具有负值,本质上是反转报告中的费用。
这个:
| Charge | Account | Type | Invoice | GST |
|------------------|---------|-----------------|---------|-----|
| Apple | 123 | Product | 0 | |
| Banana | 123 | Product | 0 | |
| Orange | 456 | Product | 0 | |
| Orange (Freight) | 456 | Product Freight | | 0 |
会变成这样:
| Charge | Account | Type | Invoice | GST |
|------------------|---------|-----------------|---------|-----|
| Apple | 123 | Product | 0 | |
| Banana | 123 | Product | 0 | |
| Orange | 456 | Product | 0 | |
| Orange | 456 | Product Freight | | 0 |
| Orange (Freight) | 456 | Product Freight | () | 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
我认为以下内容会重复目标行 - 仍然不确定如何添加负度量:
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;
我在 SSRS 中有一份财务报告,运行不符合 MDX 查询。报告 运行,导出到 Excel,然后加载到财务系统,如 SAP。
我需要为属于特定类别的费用添加 "reversal" 行。例如(下图)对于 "Type" 为 "Product Freight" 的任何内容,我还想包含一个 EXTRA 行,该行具有负值,本质上是反转报告中的费用。
这个:
| Charge | Account | Type | Invoice | GST |
|------------------|---------|-----------------|---------|-----|
| Apple | 123 | Product | 0 | |
| Banana | 123 | Product | 0 | |
| Orange | 456 | Product | 0 | |
| Orange (Freight) | 456 | Product Freight | | 0 |
会变成这样:
| Charge | Account | Type | Invoice | GST |
|------------------|---------|-----------------|---------|-----|
| Apple | 123 | Product | 0 | |
| Banana | 123 | Product | 0 | |
| Orange | 456 | Product | 0 | |
| Orange | 456 | Product Freight | | 0 |
| Orange (Freight) | 456 | Product Freight | () | 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
我认为以下内容会重复目标行 - 仍然不确定如何添加负度量:
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;