MDX 查询需要炫耀一个级别
MDX query needed to show off one level
我已经计算了我的毛利并想显示为总计,但是,如果我 运行 此代码显示每个帐户摘要的收入和销售成本之间的差异结果,如下所示输出
这很尴尬我的要求是收入和销售成本必须显示帐户摘要,但毛利润必须只是总计(一行)而不是探索每个帐户摘要。在 MDX 中是否有任何 way/any 命令可以执行此操作?
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];
也许您的脚本非常接近。你为什么把这个成员包括在你的计算中? [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];
这就是我一直在寻找的解决方案。我真的很感谢 whytheq - 他的代码帮助我做到了这一点:
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];
我已经计算了我的毛利并想显示为总计,但是,如果我 运行 此代码显示每个帐户摘要的收入和销售成本之间的差异结果,如下所示输出
这很尴尬我的要求是收入和销售成本必须显示帐户摘要,但毛利润必须只是总计(一行)而不是探索每个帐户摘要。在 MDX 中是否有任何 way/any 命令可以执行此操作?
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];
也许您的脚本非常接近。你为什么把这个成员包括在你的计算中? [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];
这就是我一直在寻找的解决方案。我真的很感谢 whytheq - 他的代码帮助我做到了这一点:
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];