我有一个查询;
SELECT
[Measures].[PersonelMasrafTutarSicileGore] ON COLUMNS,
non empty
[DimDimension2CostCenterView].[CostCenterFullName].[CostCenterFullName] *
[DimSicilBilgileri].[NAME].[NAME] *
[DimSicilBilgileri].[SURNAME].[SURNAME] *
[DimSicilBilgileri].[RSICILNO].[RSICILNO]*
[DimLedgerMasrafHierarchy].[GVHFMMASRAFCINSI].GVHFMMASRAFCINSI].ALLMEMBERS *
[DimLedgerMasrafHierarchy].[ACCOUNTNUM].[ACCOUNTNUM].ALLMEMBERS *
[DimDateView].[MonthOfYear].[MonthOfYear]*
[DimDateView].[MonthName].[MonthName]
ON ROWS
FROM ( SELECT ( STRTOSET("{[DimDateView].[Year].&[2016]}", CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET("{[BridgeSatisMuhasebeMM].[DimDimension2CostCenterViewKey].&[S_IHRACAT]}", CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET("{[DimDateView].[MonthOfYear].&[1],[DimDateView].[MonthOfYear].&[2]}", CONSTRAINED) ) ON COLUMNS
FROM [Model])))
结果是;
哪个好。我想要实现的是将有缺口的月份值添加为0.例如,选择的MonthOfYear值为1和2.因此对于第一行和accountnum 760.454.02我想得到MonthOfYear 2的行并且值为0.就像那样,对于accountnum 760.402.01的第二行,MonthOfYear 1应该有0个值。如果可能,如果没有[DimLedgerMasrafHierarchy]的值,我想得到两个给定MonthOfYear值的0值,如;
我怎样才能做到这一点?
答案 0 :(得分:0)
也许只是使用NonEmpty
和NON EMPTY
:
SELECT
[Measures].[PersonelMasrafTutarSicileGore] ON COLUMNS,
NonEmpty(
[DimDimension2CostCenterView].[CostCenterFullName].[CostCenterFullName]
*[DimSicilBilgileri].[NAME].[NAME]
*[DimSicilBilgileri].[SURNAME].[SURNAME]
*[DimSicilBilgileri].[RSICILNO].[RSICILNO]
*[DimLedgerMasrafHierarchy].[GVHFMMASRAFCINSI].GVHFMMASRAFCINSI].ALLMEMBERS
,[Measures].[PersonelMasrafTutarSicileGore]
)
*[DimLedgerMasrafHierarchy].[ACCOUNTNUM].[ACCOUNTNUM].ALLMEMBERS
*[DimDateView].[MonthOfYear].[MonthOfYear]
*[DimDateView].[MonthName].[MonthName]
ON ROWS
FROM ( SELECT ( STRTOSET("{[DimDateView].[Year].&[2016]}", CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET("{[BridgeSatisMuhasebeMM].[DimDimension2CostCenterViewKey].&[S_IHRACAT]}", CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET("{[DimDateView].[MonthOfYear].&[1],[DimDateView].[MonthOfYear].&[2]}", CONSTRAINED) ) ON COLUMNS
FROM [Model])));
我不完全理解您的评论 - 尝试将[DimLedgerMasrafHierarchy]
维度中的所有层次结构移出NonEmpty
函数:
SELECT
[Measures].[PersonelMasrafTutarSicileGore] ON COLUMNS,
NonEmpty(
[DimDimension2CostCenterView].[CostCenterFullName].[CostCenterFullName]
*[DimSicilBilgileri].[NAME].[NAME]
*[DimSicilBilgileri].[SURNAME].[SURNAME]
*[DimSicilBilgileri].[RSICILNO].[RSICILNO]
,[Measures].[PersonelMasrafTutarSicileGore]
)
*[DimLedgerMasrafHierarchy].[GVHFMMASRAFCINSI].GVHFMMASRAFCINSI].ALLMEMBERS
*[DimLedgerMasrafHierarchy].[ACCOUNTNUM].[ACCOUNTNUM].ALLMEMBERS
*[DimDateView].[MonthOfYear].[MonthOfYear]
*[DimDateView].[MonthName].[MonthName]
ON ROWS
FROM ( SELECT ( STRTOSET("{[DimDateView].[Year].&[2016]}", CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET("{[BridgeSatisMuhasebeMM].[DimDimension2CostCenterViewKey].&[S_IHRACAT]}", CONSTRAINED) ) ON COLUMNS
FROM ( SELECT ( STRTOSET("{[DimDateView].[MonthOfYear].&[1],[DimDateView].[MonthOfYear].&[2]}", CONSTRAINED) ) ON COLUMNS
FROM [Model])));