输出MDX的附加总行数

输出MDX的附加总行数,mdx,Mdx,如何从以下MDX中获取要输出的附加总行: SELECT { [Measures].[Internet Sales Amount] ,[Measures].[Internet Gross Profit] ,[Measures].[Sales Amount] } ON COLUMNS ,NON EMPTY {[Customer].[City].[City] * [Product].[Product].[Product]} ON ROWS FROM [Adve

如何从以下MDX中获取要输出的附加总行:

SELECT 
  {
    [Measures].[Internet Sales Amount]
   ,[Measures].[Internet Gross Profit]
   ,[Measures].[Sales Amount]
  } ON COLUMNS
 ,NON EMPTY 
    {[Customer].[City].[City] * [Product].[Product].[Product]} ON ROWS
FROM [Adventure Works]
WHERE 
  (
    [Date].[Fiscal Weeks].[Fiscal Year].&[2007]
   ,[Employee].[Employee Department].[Employee].&[105]
  );
我可以从纯SQL中得到。下面是SQL聚合模拟

select 
    [Customer].[City].[City],[Product].[Product].[Product]
    , sum([Measures].[Internet Sales Amount]) as [Measures].[Internet Sales Amount]
    , sum([Measures].[Internet Gross Profit]) as [Measures].[Internet Gross Profit]
    , sum([Measures].[Sales Amount]) as [Measures].[Sales Amount]
from  [Adventure Works]
where   [Date].[Fiscal Weeks].[Fiscal Year].&[2007] and [Employee].[Employee Department].[Employee].&[105] 
group by [Customer].[City].[City],[Product].[Product].[Product]

union 

select 
    'Total'  ,null 
    , sum([Measures].[Internet Sales Amount]) as [Measures].[Internet Sales Amount]
    , sum([Measures].[Internet Gross Profit]) as [Measures].[Internet Gross Profit]
    , sum([Measures].[Sales Amount]) as [Measures].[Sales Amount]
from  [Adventure Works]
where   [Date].[Fiscal Weeks].[Fiscal Year].&[2007] and [Employee].[Employee Department].[Employee].&[105] 

是否需要额外的单个“所有成员”输出

Select 
{
    [Measures].[Internet Sales Amount],
    [Measures].[Internet Gross Profit],
    [Measures].[Sales Amount]
} on 0,
{
    [Customer].[City].[All] *
    [Product].[Product].[All]
    +
    NonEmptyCrossJoin( 
        [Customer].[City].[City].Members,
        [Product].[Product].[Product].Members,
        2
    ) 
} on 1
From [Adventure Works]
Where 
(
    [Date].[Fiscal Weeks].[Fiscal Year].&[2007],
    [Employee].[Employee Department].[Employee].&[105]
)

顺便说一下,有。此外,您可能会发现对理解MDX交叉连接很有用。

是否需要额外的单个“所有成员”输出

Select 
{
    [Measures].[Internet Sales Amount],
    [Measures].[Internet Gross Profit],
    [Measures].[Sales Amount]
} on 0,
{
    [Customer].[City].[All] *
    [Product].[Product].[All]
    +
    NonEmptyCrossJoin( 
        [Customer].[City].[City].Members,
        [Product].[Product].[Product].Members,
        2
    ) 
} on 1
From [Adventure Works]
Where 
(
    [Date].[Fiscal Weeks].[Fiscal Year].&[2007],
    [Employee].[Employee Department].[Employee].&[105]
)

顺便说一下,有。此外,您可能会发现了解MDX交叉连接很有用。

Danylo的答案可能不是完美的方法:

  • 这是错误的。他使用以下代码:
    [Customer].[City].[All]*[Product].[Product].[All].[code>试图交叉连接成员,但他需要显式创建这些单个成员集:
    {[Customer].[City].[All]}*{[Product].[Product].[All]}
  • 从我所读到的
    NonEmptyCrossJoin
    是过去的残余,最好避免:
  • 如果我在1中进行了详细的更正,脚本只返回1行,我假设这不是必需的
  • 我只想使用All成员添加一个元组,如下所示:

    SELECT 
      {
        [Measures].[Internet Sales Amount]
       ,[Measures].[Internet Gross Profit]
       ,[Measures].[Sales Amount]
      } ON COLUMNS
     ,NON EMPTY 
        {
          (
            [Customer].[City].[All]
           ,[Product].[Product].[All]
          )
         ,{[Customer].[City].[City] * [Product].[Product].[Product]}
        } ON ROWS
    FROM [Adventure Works]
    WHERE 
      (
        [Date].[Fiscal Weeks].[Fiscal Year].&[2007]
       ,[Employee].[Employee Department].[Employee].&[105]
      );
    

    Danylo的答案可能不是完美的方法:

  • 这是错误的。他使用以下代码:
    [Customer].[City].[All]*[Product].[Product].[All].[code>试图交叉连接成员,但他需要显式创建这些单个成员集:
    {[Customer].[City].[All]}*{[Product].[Product].[All]}
  • 从我所读到的
    NonEmptyCrossJoin
    是过去的残余,最好避免:
  • 如果我在1中进行了详细的更正,脚本只返回1行,我假设这不是必需的
  • 我只想使用All成员添加一个元组,如下所示:

    SELECT 
      {
        [Measures].[Internet Sales Amount]
       ,[Measures].[Internet Gross Profit]
       ,[Measures].[Sales Amount]
      } ON COLUMNS
     ,NON EMPTY 
        {
          (
            [Customer].[City].[All]
           ,[Product].[Product].[All]
          )
         ,{[Customer].[City].[City] * [Product].[Product].[Product]}
        } ON ROWS
    FROM [Adventure Works]
    WHERE 
      (
        [Date].[Fiscal Weeks].[Fiscal Year].&[2007]
       ,[Employee].[Employee Department].[Employee].&[105]
      );