1
我必須以奇怪的方式對某些事物進行計數,並且它在大多數情況下都有效 - 無論是在葉子上還是在多個維度上的更高聚合級別。但它沒有給出一個特定維度的正確聚合值。SSAS中計算度量值聚合的不同扭曲
我目前所面對的是...
CREATE MEMBER CURRENTCUBE.[Measures].[Active Commitments]
AS NULL,
FORMAT_STRING = '#,#',
VISIBLE = 1;
SCOPE (DESCENDANTS([Date Dimension].[Fiscal Year Hierarchy],,AFTER));
[Measures].[Active Commitments] =
iif([Constituent Activity].[Type].currentMember.Properties("Name")="Correspondence",
sum(([Commitment Dates].[Start Date], NULL: [Date Dimension].[Fiscal Year Hierarchy]), [Measures].[Commitment Count]),
sum(([Commitment Dates].[First Funded Date], NULL: [Date Dimension].[Fiscal Year Hierarchy]), [Measures].[Commitment Count]))
- sum(([Commitment Dates].[Stop Date],[Commitment].[Was Commitment Ever Active].[Sometime Active], NULL: [Date Dimension].[Fiscal Year Hierarchy]), [Measures].[Commitment Count]);
END SCOPE;
SCOPE (DESCENDANTS([Date Dimension].[Fiscal Year Hierarchy],,AFTER));
<Similar to above>
正如你所看到的,複雜的是,一種類型的「承諾」開始在[Start Date]
和其他人在[First Funded Date]
開始。
只要選擇了多個成員[Constituent Activity]
,就會失敗,因爲在這種情況下,SCOPE語句中使用currentMember
無效。例如,下面的MDX成功執行,但輸出#Error
-
select
[Measures].[Active Commitments] on columns
,[Date Dimension].[Fiscal Year Hierarchy].[Fiscal Year].&[2011\12] on rows
from Compass3
where
{[Constituent Activity].[Description].[XYZ]
,[Constituent Activity].[Description].[ABC]}
我想我需要在SCOPE語句中編碼爲遞歸...
if a single member of [Constituent Activity] is current
then use the calc as defined above
else use [Measures].[Active Commitments] = sum(all selected members of [Constituent Activity], [Measures].[Active Commitments])
...但如何將我寫這個?
謝謝比爾。我確實擁有控制權,但它是一個既定的立方體,我繼承了它,並試圖儘可能接近表面以避免不必要的副作用。當前處理日期的結構非常複雜,因此添加另一個日期非常棘手。 – MattClarke