我正在尝试在我的多维数据集中创建一个计算度量,该度量将根据显示的日期维度而有所不同。我认为SCOPE
会得到我想要的东西,但它似乎做了最后一次计算。
CREATE MEMBER CURRENTCUBE.[Measures].[Sales Prior]
AS (
Null
),
VISIBLE = 1 , ASSOCIATED_MEASURE_GROUP = 'Sales';
SCOPE ([Sales and Forecast Date].[Calendar Year].Members, [Measures].[Sales Prior]);
this = ([Sales and Forecast Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
end scope;
SCOPE ([Sales Requested Ship Date].[Calendar Year].Members, [Measures].[Sales Prior]);
this = ([Sales Requested Ship Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
end scope;
SCOPE ([Sales Ship Date].[Calendar Year].Members, [Measures].[Sales Prior]);
this = ([Sales Ship Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
end scope;
此代码段仅适用于发货日期维度,并为其他2提供NULL
。
我也试过嵌套SCOPE
语句,但它做了同样的事情。
答案 0 :(得分:1)
我最好的猜测是你的日历年。会员"返回[全部]这意味着当你实际上不想使用该层次结构时,它仍然在SCOPE中,因为[All]实际上是ROOT。因此,就像你提到的那样,只有SCOPES中提到的最后一个层次结构正在工作,如果切换SCOPES的顺序,另一个应该开始工作,因为正在评估所有SCOPES但实际只显示了最后一个。尝试从SCOPE中删除[All]。
SCOPE ([Sales and Forecast Date].[Calendar Year].[All].CHILDREN, [Measures].[Sales Prior]);
this = ([Sales and Forecast Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
end scope;
SCOPE ([Sales Requested Ship Date].[Calendar Year].[All].CHILDREN, [Measures].[Sales Prior]);
this = ([Sales Requested Ship Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
end scope;
SCOPE ([Sales Ship Date].[Calendar Year].[All].CHILDREN, [Measures].[Sales Prior]);
this = ([Sales Ship Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
end scope;
您正在为该级别执行范围,只在该级别上工作才有意义,)
如果您拥有所需级别的层次结构,可以尝试以下方法:
在您的范围内使用DESCENDANTS(,, AFTER)进行处理,以便层次结构中的所有成员都在SCOPE中。 我会这样试试:
SCOPE ([Measures].[Sales Prior]);
this = null;
SCOPE (DESCENDANTS([Sales and Forecast Date].[Calendar Year].[All].CHILDREN,,AFTER));
this = ([Sales and Forecast Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
END SCOPE;
SCOPE (DESCENDANTS([Sales Requested Ship Date].[Calendar Year].[All].CHILDREN,,AFTER));
this = ([Sales Requested Ship Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
END SCOPE;
SCOPE (DESCENDANTS([Sales Ship Date].[Calendar Year].[All].CHILDREN,,AFTER));
this = ([Sales Ship Date].[Calendar Year].CurrentMember.PREVMEMBER, [Measures].[Sales Amount]);
END SCOPE;
END SCOPE;
答案 1 :(得分:0)