MDX联盟结果集

时间:2016-09-28 07:00:48

标签: reporting-services ssas mdx

请原谅我,我是MDX的新手。我有一个问题,我真的很挣扎。我正在尝试构建一个按客户分组的SSRS报告。问题是,第一组是由一组客户组成的,第二组是不在第一组中的所有组。下面是我试图加入的两个脚本......

index.html

和...

WITH
  MEMBER [Measures].[Key for Today] AS 
    Format
    (
      Now(),'yyyyMMdd'
    ) 
  MEMBER [Measures].[Today string] AS 
    '[Date].[Dates].[Day].&[' + [Measures].[Key for Today] + ']' 

  MEMBER [Measures].[Quantity Shipped MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Quantity Shipped]
    ) 
  MEMBER [Measures].[Quantity Shipped YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Quantity Shipped]
    ) 
  MEMBER [Measures].[Sales Amount MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Sales Amount]
    ) 
  MEMBER [Measures].[Sales Amount YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Sales Amount]
    ) 
  MEMBER [Measures].[Cost Amount MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Cost Amount - Sales]
    ) 
  MEMBER [Measures].[Cost Amount YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Cost Amount - Sales]
    ) 
  MEMBER [Measures].[Sales Margin MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Sales Margin]
    ) 
  MEMBER [Measures].[Sales Margin YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Sales Margin]
    )
 MEMBER [Measures].[Forecast Quantity MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Quantity]
    ) 
  MEMBER [Measures].[Forecast Quantity YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Quantity]
    ) 
  MEMBER [Measures].[Forecast Turnover MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Total Turnover]
    ) 
  MEMBER [Measures].[Forecast Turnover YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Total Turnover]
    ) 
  MEMBER [Measures].[Forcast Cost MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Total Cost]
    ) 
  MEMBER [Measures].[Forecast Cost YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Total Cost]
    ) 
  MEMBER [Measures].[Forecast Margin MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Margin]
    ) 
  MEMBER [Measures].[Forecast Margin YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Forecast Margin]
    )
  MEMBER [Measures].[Budget Quantity MTD] AS 
    Sum
    (
      MTD([Date].[Dates].CurrentMember)
     ,[Measures].[Budget Quantity]
    ) 
  MEMBER [Measures].[Budget Quantity YTD] AS 
    Sum
    (
      YTD([Date].[Dates].CurrentMember)
     ,[Measures].[Budget Quantity]
    )  
   MEMBER [Measures].[Budget Turnover MTD] AS 
     Sum
     (
       MTD([Date].[Dates].CurrentMember)
      ,[Measures].[Budget Total Turnover]
     ) 
   MEMBER [Measures].[Budget Turnover YTD] AS 
     Sum
     (
       YTD([Date].[Dates].CurrentMember)
      ,[Measures].[Budget Total Turnover]
     ) 
   MEMBER [Measures].[Budget Cost MTD] AS 
     Sum
     (
       MTD([Date].[Dates].CurrentMember)
      ,[Measures].[Budget Total Cost]
     ) 
   MEMBER [Measures].[Budget Cost YTD] AS 
     Sum
     (
       YTD([Date].[Dates].CurrentMember)
      ,[Measures].[Budget Total Cost]
     ) 
   MEMBER [Measures].[Budget Margin MTD] AS 
     Sum
     (
       MTD([Date].[Dates].CurrentMember)
      ,[Measures].[Budget Margin]
     ) 
   MEMBER [Measures].[Budget Margin YTD] AS 
     Sum
     (
       YTD([Date].[Dates].CurrentMember)
      ,[Measures].[Budget Margin]
    )
SELECT 
  {
    [Measures].[Quantity Shipped MTD],
    [Measures].[Sales Amount MTD],
    [Measures].[Cost Amount MTD],
    [Measures].[Sales Margin MTD],  
    [Measures].[Margin %],
    [Measures].[Forecast Quantity MTD],
    [Measures].[Forecast Turnover MTD],
    [Measures].[Forcast Cost MTD],
    [Measures].[Forecast Margin MTD],
    [Measures].[Margin %],
    [Measures].[Budget Quantity MTD],
    [Measures].[Budget Turnover MTD],
    [Measures].[Budget Cost MTD],
    [Measures].[Budget Margin MTD],
    [Measures].[Margin %],
    [Measures].[Quantity Shipped YTD],
    [Measures].[Sales Amount YTD],
    [Measures].[Cost Amount YTD],
    [Measures].[Sales Margin YTD],  
    [Measures].[Margin %],
    [Measures].[Forecast Quantity YTD],
    [Measures].[Forecast Turnover YTD],
    [Measures].[Forecast Cost YTD],
    [Measures].[Forecast Margin YTD],
    [Measures].[Margin %],
    [Measures].[Budget Quantity YTD],
    [Measures].[Budget Turnover YTD],
    [Measures].[Budget Cost YTD],
    [Measures].[Budget Margin YTD],
    [Measures].[Margin %]
  } ON COLUMNS, NON EMPTY
  {
    [Customer].[Business Type].[Business Type].ALLMEMBERS*
    [Customer Sales].[Summary Prod Group 1].[Summary Prod Group 1].ALLMEMBERS} On Rows
From
(
    SELECT 
    {
      [Customer].[Customer].&[5637]
     ,[Customer].[Customer].&[4125]
     ,[Customer].[Customer].&[1727]
    } ON 0
   ,{[Customer].[Business Type].&[Export]} ON 1
   ,-
      {
        [Customer Sales].[Summary Prod Group 1].&[Missing Product Group]
      } ON 2
From [Sales])
Where
StrToMember
    (
      [Measures].[Today string]
     ,constrained
    )

两个脚本之间的唯一区别是我选择客户的减号。

请帮忙。 TX。

0 个答案:

没有答案