MDX NON EMPTY多维轴

我正在写VBA中的MDX代码,我必须把数据放在Excel中。

SELECT { [Measures].[VL PROD], [Measures].[Impostos], [Measures].[RecLiqProd], [Measures.[ValorMgProd], [Measures].[QTD ITENS] ,[Measures].[VL FRETE] } ON 0, NON EMPTY ( { Descendants( [Produto].[Produto].[Departamento], 5 ) } ) ON 1, NON EMPTY ( { [Data Pedido].[Data].[Ano].&[2014].&[2].&[6].&[1]:[Data Pedido].[Data].[Ano].&[2014].&[2].&[6].&[26] } ON 2, NON EMPTY ( { [Unidade Negócio].[Unidade Negócio].&[Unidade 1], [Unidade Negócio].[Unidade Negócio].&[Unidade 2], [Unidade Negócio].[Unidade Negócio].&[Unidade 3] } ) ON 3 FROM [Rentabilidade] WHERE ( - Extract( { [Livre de Debito] }, [Meio Pagamento].[Meio Pagamento]) ) For i = 0 To cst.Axes(1).Positions.Count - 1 For j = 0 To cst.Axes(2).Positions.Count - 1 For k = 0 To cst.Axes(3).Positions.Count - 1 'If cst(0, i, j, k) * cst(1, i, j, k) * cst(2, i, j, k) * cst(3, i, j, k) * cst(4, i, j, k) * cst(5, i, j, k) <> "" Then Cells(a, 1) = cst.Axes(1).Positions(i).Members(0).Caption Cells(a, 2) = cst.Axes(2).Positions(j).Members(0).Caption Cells(a, 3) = cst.Axes(3).Positions(k).Members(0).Caption Cells(a, 4) = cst(0, i, j, k) Cells(a, 5) = cst(1, i, j, k) Cells(a, 6) = cst(2, i, j, k) Cells(a, 7) = cst(3, i, j, k) Cells(a, 8) = cst(4, i, j, k) Cells(a, 9) = cst(5, i, j, k) a = a + 1 'End If Next k Next j Next i 

问题是我得到了大量的空行; 我想知道如何删除它们。

例如,我得到以下内容:

 Id | Data | Bandeira | impostos | recliq | ValorMrg | Qtd Item | Vl Frete 10 | 40230 | Unidade 1 | | | | | 10 | 40230 | Unidade 2 | | | | | 10 | 40230 | Unidade 3 | 0,2 | 2032 | 100 | 1000 | 323 32 | 40231 | Unidade 3 | | | | | 32 | 40232 | Unidade 3 | | | | | 32 | 40233 | Unidade 3 | 0,2 | 32 | 321 | 5045 | 323 

我以为我已经理解了非空和非空的区别(来自http://beyondrelational.com/modules/2/blogs/65/posts/11569/mdx-non-empty-vs-nonempty.aspx )我错过了什么。

谁能帮我?

如果你想有一个二维的报告,为什么你运行一个四维查询?

我会认为下面的MDX

 SELECT { [Measures].[VL PROD], [Measures].[Impostos], [Measures].[RecLiqProd], [Measures.[ValorMgProd], [Measures].[QTD ITENS] ,[Measures].[VL FRETE] } ON 0, NON EMPTY { Descendants( [Produto].[Produto].[Departamento], 5 ) } ) * { [Data Pedido].[Data].[Ano].&[2014].&[2].&[6].&[1]:[Data Pedido].[Data].[Ano].&[2014].&[2].&[6].&[26] } * { [Unidade Negócio].[Unidade Negócio].&[Unidade 1], [Unidade Negócio].[Unidade Negócio].&[Unidade 2], [Unidade Negócio].[Unidade Negócio].&[Unidade 3] } ) ON 1 FROM [Rentabilidade] WHERE ( - Extract( { [Livre de Debito] }, [Meio Pagamento].[Meio Pagamento]) ) 

会提供你想要的。 在这种情况下,将针对三个层次的跨产品的每个元组针对列轴来评估Axis 1上的NON EMPTY

当然,那么你将不得不相应地改变你的VBA代码,因为你现在只有一个轴的行,但它有三个位置,而不是一个。