我已经计算了我的毛利并希望显示为总数但是,如果我运行此代码,它会显示收入和销售成本之间的差异结果与每个帐户摘要,如下面的输出
非常尴尬我的要求是收入和销售成本必须显示帐户摘要,但总利润必须只是总计(一行)而不是每个帐户摘要。在MDX中有没有办法/任何命令?
WITH
MEMBER [Total] AS
(
[Measures].[Amount]
,[Dim Account].[Account Summary].CurrentMember
)
MEMBER TotalIncome AS
(
[Measures].[Amount]
,[Dim Account].[Account Type].&[Income]
,[Dim Account].[Account Summary].[All]
)
MEMBER TotalCOGS AS
(
[Measures].[Amount]
,[Dim Account].[Account Type].&[Cost of Sales]
,[Dim Account].[Account Summary].[All]
)
MEMBER [Dim Account].[Account Type].[Gross Profit] AS
TotalIncome - TotalCOGS
SELECT
NON EMPTY
[Total] ON COLUMNS
,NON EMPTY
(
{
[Dim Account].[Account Type].&[Income]
,[Dim Account].[Account Type].&[Cost of Sales]
,[Dim Account].[Account Type].[Gross Profit]
,[Dim Account].[Account Type].&[Expenses]
,[Dim Account].[Account Type].&[Other Income]
,[Dim Account].[Account Type].&[Other Expense]
}
,NonEmpty([Dim Account].[Account Summary].[Account Summary])
,NonEmpty([Dim Fiscal Year].[HierarchyFiscal].[E Month].&[2016]&[August])
,NonEmpty([Dim Branch].[HierarchyB-T-C].[Branch Code].&[bfy])
) ON ROWS
FROM [CubeProfitLoss];
答案 0 :(得分:1)
也许你的剧本非常接近。你为什么要把这个成员包括在你的计算中? [Dim Account].[Account Summary].[All]
WITH
MEMBER [Dim Account].[Account Type].[Gross Profit] AS
(
[Dim Account].[Account Type].&[Income]
,[Dim Account].[Account Summary].[All]
)
-
(
[Dim Account].[Account Type].&[Cost of Sales]
,[Dim Account].[Account Summary].[All]
)
MEMBER [Dim Account].[Account Type].[Gross Profit V2] AS
(
[Dim Account].[Account Type].&[Income]
)
-
(
[Dim Account].[Account Type].&[Cost of Sales]
)
SELECT
NON EMPTY
[Measures].[Amount] ON 0
,NON EMPTY
{
[Dim Account].[Account Type].&[Income]
,[Dim Account].[Account Type].&[Cost of Sales]
,[Dim Account].[Account Type].[Gross Profit]
,[Dim Account].[Account Type].[Gross Profit V2]
,[Dim Account].[Account Type].&[Expenses]
,[Dim Account].[Account Type].&[Other Income]
,[Dim Account].[Account Type].&[Other Expense]
}
*[Dim Account].[Account Summary].[Account Summary]
*[Dim Fiscal Year].[HierarchyFiscal].[E Month].&[2016]&[August]
*[Dim Branch].[HierarchyB-T-C].[Branch Code].&[bfy]
ON 1
FROM [CubeProfitLoss];
答案 1 :(得分:0)
这是我正在寻找的解决方案。我真的很感激为什么theq - 他的代码帮助我实现了这个目标:
WITH
MEMBER [Dim Account].[Account Type].[Gross Profit] AS
([Dim Account].[Account Type].&[Income])
-([Dim Account].[Account Type].&[Cost of Sales])
SELECT
NON EMPTY
[Measures].[Amount] ON 0
,
NON EMPTY
(
{
([Dim Account].[Account Type].&[Income],
[Dim Account].[Account Summary].[Account Summary])
,([Dim Account].[Account Type].&[Cost of Sales],
[Dim Account].[Account Summary].[Account Summary])
,([Dim Account].[Account Type].[Gross Profit],
[Dim Account].[Account Summary].[All])
,([Dim Account].[Account Type].&[Expenses],
[Dim Account].[Account Summary].[Account Summary])
,([Dim Account].[Account Type].&[Other Income],
[Dim Account].[Account Summary].[Account Summary])
,([Dim Account].[Account Type].&[Other Expense],
[Dim Account].[Account Summary].[Account Summary])
}
*[Dim Fiscal Year].[HierarchyFiscal].[E Month].&[2016]&[August]
*[Dim Branch].[HierarchyB-T-C].[Branch Code].&[bfy]
)
ON 1
FROM [CubeProfitLoss];