Force mdx query to return column names

六月ゝ 毕业季﹏ 提交于 2019-12-02 00:55:41

I will check before the select if your NonEmpty clause will return a void set, and in that case put on row a dummy set that will be return to powerpivot at least 1 row. Something like:

WITH 
SET [mySet] as NON EMPTY ({Filter([DimLocalDate].[Date].&[20110101]:[DimLocalDate].[Date].&[20120101], [JobStatus].[JobStatus].&[1] })
SET [myRealSet] as IIF(COUNT([mySet]) > 0, [mySet], {[DummySet]}) 
SELECT NON EMPTY {[Measures].[Measure1]} ON COLUMNS,
[myRealSet] ON ROWS
FROM [TheCube]

would help?

re SSIS error: [MEMBER_CAPTION] cannot be found at the datasource.

Thanks your solution helped me. I had the same issue using SSIS, SSAS to output a flat file report

i'll post an extended example to help others define the dummy set. Please note that the date is inserted into MDX script dynamically.

SSIS throws an exception when no data exists for the date, and therefore no results are returned. This messes up the column order

--create a blank set so that data is still returned when there are no results for that date
set [BlankRowSet] as 
([Activity Period].[Days].[Day].&[2014-02-02T00:00:00], [Well].[Location].[Location].&[])

--create the active set as the crossjoin between Days, Wells
set [ActiveSet] as 
nonempty([Activity Period].[Days].[Day].members * [Well].[Location].[Location].members )

SET [RealSet] as IIF(COUNT([ActiveSet]) > 0, [ActiveSet], {[BlankRowSet]}) 


select {[Measures].[Total boe]} ON COLUMNS 
,[RealSet] ON ROWS 
FROM 
(select {[Activity Period].[Days].[Day].&[2014-02-02T00:00:00]:[Activity Period].[Days].[Day].&    [2014-02-02T00:00:00]} on 0 from [Volumes] )

where 
[Scenario].[All Scenarios].[Category].&[PVR Sales Estimates] 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!