添加参数后,度量消失

时间:2017-11-14 19:25:45

标签: sql sql-server reporting-services mdx ssrs-2012

我有这样的数据集MDX查询:

 SELECT NON EMPTY { 
[Measures].[InventarioDirectoInventario_Inventario],
 [Measures].[InventarioDirectoInventario_InventarioAcumulado], 
[Measures].[InventarioDirectoVentas_VentaAcumulada],
 [Measures].[InventarioDirectoVentas_Ventas] } ON COLUMNS, NON EMPTY { (
[Dim_Tiempo_].[Anio].[Anio].ALLMEMBERS 
* [Dim_Tiempo_].[Mes].[Mes].ALLMEMBERS 
* [Dim_Tiempo_].[NombreMesAbreviado].[NombreMesAbreviado].ALLMEMBERS
 * [Dim_PlantaCentro_].[IdGrupo].[IdGrupo].ALLMEMBERS 
* [Dim_PlantaCentro_].[NombreGrupo].[NombreGrupo].ALLMEMBERS 
* [Dim_PlantaCentro_].[IdDivision].[IdDivision].ALLMEMBERS 
* [Dim_PlantaCentro_].[NombreDivision].[NombreDivision].ALLMEMBERS 
* [Dim_PlantaCentro_].[IdPlanta].[IdPlanta].ALLMEMBERS 
* [Dim_PlantaCentro_].[Planta].[Planta].ALLMEMBERS 
* [Dim_ConceptosInventario_].[keyClave].[keyClave].ALLMEMBERS 
* [Dim_ConceptosInventario_].[sNombreConcepto].[sNombreConcepto].ALLMEMBERS ) } 
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM [BSC] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

它正确运行并返回所有字段,当我想添加参数AnioMes时会出现问题:

 DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS 
FROM ( SELECT ( STRTOSET(@DimTiempoMes, CONSTRAINED) ) ON COLUMNS 
FROM ( SELECT ( STRTOSET(@DimTiempoAnio, CONSTRAINED) ) ON COLUMNS FROM [BSC])) 
CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS

出于某种原因

[Measures].[InventarioDirectoVentas_VentaAcumulada]

[Measures].[InventarioDirectoVentas_Ventas]

从我的返回领域消失,我不知道为什么。这个字段的特殊之处在于它们可以返回null但是在添加参数之前它返回没有问题,现在使用MesAnio的过滤器它只是不返回字段,它们消失了。有人知道那里有什么问题吗?此致

1 个答案:

答案 0 :(得分:0)

在列集之前删除非空:

SELECT { 
[Measures].[InventarioDirectoInventario_Inventario],
 [Measures].[InventarioDirectoInventario_InventarioAcumulado], 
[Measures].[InventarioDirectoVentas_VentaAcumulada],
 [Measures].[InventarioDirectoVentas_Ventas] } ON COLUMNS, NON EMPTY { (
[Dim_Tiempo_].[Anio].[Anio].ALLMEMBERS 
* [Dim_Tiempo_].[Mes].[Mes].ALLMEMBERS 
* [Dim_Tiempo_].[NombreMesAbreviado].[NombreMesAbreviado].ALLMEMBERS
 * [Dim_PlantaCentro_].[IdGrupo].[IdGrupo].ALLMEMBERS 
* [Dim_PlantaCentro_].[NombreGrupo].[NombreGrupo].ALLMEMBERS 
* [Dim_PlantaCentro_].[IdDivision].[IdDivision].ALLMEMBERS 
* [Dim_PlantaCentro_].[NombreDivision].[NombreDivision].ALLMEMBERS 
* [Dim_PlantaCentro_].[IdPlanta].[IdPlanta].ALLMEMBERS 
* [Dim_PlantaCentro_].[Planta].[Planta].ALLMEMBERS 
* [Dim_ConceptosInventario_].[keyClave].[keyClave].ALLMEMBERS 
* [Dim_ConceptosInventario_].[sNombreConcepto].[sNombreConcepto].ALLMEMBERS ) } 
DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_VALUE, MEMBER_UNIQUE_NAME ON ROWS FROM [BSC] CELL PROPERTIES VALUE, BACK_COLOR, FORE_COLOR, FORMATTED_VALUE, FORMAT_STRING, FONT_NAME, FONT_SIZE, FONT_FLAGS