对同一 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
First, my knowledge of MDX is very limited
Basically, I have 2 queries; one with HQ sales per departments and one with stock room sales per departments. I would like to return the results of the department sales of the stock room followed by the department sales of the HQ in one go.
Thanks in advance.
In SQL, the query should be something like this:
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'
EDIT:
I'm working on a OLAP Cube using SQL Server Reporting Services (Visual Studio 2k8R2). Here is my current MDX query:
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论