多选同一MDX查询

时间:2011-04-29 11:13:29

标签: ssrs-2008 ssas mdx

首先,我对MDX的了解非常有限

基本上,我有2个查询;一个是每个部门的总部销售额,另一个是每个部门的库房销售额。我想一次性返回库房的部门销售结果,然后是总部的部门销售。

提前致谢。

在SQL中,查询应该是这样的:

SELECT StockRoom.Code, StockRoom.Sales, StockRoom.Department, StockRoom.HQ
, (SELECT SUM(HQ.Sales) 
   FROM StockRoom HQ
   WHERE HQ.Department = StockRoom.Department
             AND HQ.HQ = StockRoom.HQ) as HQSales
FROM StockRoom StockRoom
WHERE Week = 12
      AND Year = 2011
      AND Code = 'C001'

编辑: 我正在使用SQL Server Reporting Services(Visual Studio 2k8R2)处理OLAP多维数据集。这是我当前的MDX查询:

SELECT NON EMPTY { [Measures].[CATTC], [Measures].[CATTC N-1], [Measures].[PROG] }
ON COLUMNS
, NON EMPTY { ([Stock room].[Stock room class Enseigne].[Stock room class Enseigne].ALLMEMBERS * [Stock room].[Stock room geographical dynamic hierarchy].[Stock room].ALLMEMBERS * [Product].[Product Hierarchy].[Product main class level 3].ALLMEMBERS ) }
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS
FROM ( SELECT ( STRTOSET(@TimecalendarTimecalendarweekofyear, CONSTRAINED) ) 
ON COLUMNS FROM ( SELECT ( STRTOSET(@TimecalendarTimecalendaryear, CONSTRAINED) ) 
ON COLUMNS FROM ( SELECT ( STRTOSET(@StockroomStockroomcode, CONSTRAINED) ) 
ON COLUMNS FROM [CustomNextTest]))) 
WHERE ( IIF( STRTOSET(@StockroomStockroomcode, CONSTRAINED).Count = 1, STRTOSET(@StockroomStockroomcode, CONSTRAINED), [Stock room].[Stock room code].currentmember )
, IIF( STRTOSET(@TimecalendarTimecalendaryear, CONSTRAINED).Count = 1, STRTOSET(@TimecalendarTimecalendaryear, CONSTRAINED), [Time calendar].[Time calendar year].currentmember )
, IIF( STRTOSET(@TimecalendarTimecalendarweekofyear, CONSTRAINED).Count = 1, STRTOSET(@TimecalendarTimecalendarweekofyear, CONSTRAINED), [Time calendar].[Time calendar week of year].currentmember ) ) 
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

0 个答案:

没有答案