SSRS mdx report: dimenstion on columns outputs nulls if not selected on rows also

a 夏天 提交于 2020-01-06 02:16:13

问题


(this question continues thread "SSRS mdx report: use dimension on columns", answered by @whytheq)

This correct code was built in the previouse thread:

WITH 
MEMBER [Measures].[Contacts] AS 
       IIF([Sales_step].CURRENTMEMBER IS [Sales_step].&[contact], [Measures].[Qnt], null)
MEMBER [Measures].[Clients] AS 
       IIF([Sales_step].CURRENTMEMBER IS [Sales_step].&[client], [Measures].[Qnt], null)
MEMBER [Measures].[Funded] AS 
       IIF([Sales_step].CURRENTMEMBER IS [Sales_step].&[funded], [Measures].[Qnt], null)

SELECT {[Measures].[Contacts],
        [Measures].[Clients],
        [Measures].[Funded]} ON COLUMNS,

NON EMPTY     
       crossjoin({[City].CHILDREN},                            
                 {[Sales_step].CHILDREN}) ON ROWS 

FROM ( SELECT ( [Sales_step].MEMBERS ) ON COLUMNS
FROM [SALES_PIPE])

it produces proper result:

Now I want to reduce quantity of rows to one [City] dimension only to get result like:

To do that I've tried 2 changes to the code:

(1) remove crossjoin:

NON EMPTY     
       crossjoin({[City].CHILDREN},                            
                 {[Sales_step].CHILDREN}) ON ROWS

with one [City] dimension only:

NON EMPTY [City].CHILDREN ON ROWS 

(2) leave crossjoin and incapsulate it in Extract() func:

       Extract(
       crossjoin({[City].CHILDREN},                            
                 {[Sales_step].CHILDREN}), 
       [City]) ON ROWS 

but both variants give empty cells:

How can I get brief results for one [City] dimension on rows only?


回答1:


If you try switching your measures to tuples what happens?

WITH 
  MEMBER [Measures].[Contacts] AS 
    (
      [Sales_step].&[contact]
     ,[Measures].[Qnt]
    ) 
  MEMBER [Measures].[Clients] AS 
    (
      [Sales_step].&[client]
     ,[Measures].[Qnt]
    ) 
  MEMBER [Measures].[Funded] AS 
    (
      [Sales_step].&[funded]
     ,[Measures].[Qnt]
    ) 
SELECT 
  {
    [Measures].[Contacts]
   ,[Measures].[Clients]
   ,[Measures].[Funded]
  } ON COLUMNS
 ,NON EMPTY 
    [City].Children ON ROWS
FROM 
(
  SELECT 
    [Sales_step].MEMBERS ON COLUMNS
  FROM [SALES_PIPE]
);



回答2:


Simply have:

SELECT NON EMPTY [City].CHILDREN ON ROWS,
NON EMPTY [Sales_step].CHILDREN ON COLUMNS
FROM [SALES_PIPE]
WHERE ([Measures].[Qnt])


来源:https://stackoverflow.com/questions/31648124/ssrs-mdx-report-dimenstion-on-columns-outputs-nulls-if-not-selected-on-rows-als

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