我有一個事實表,它有兩個日期Invoice Date
和Accounting Current Date
。爲了獲得請求的收入價值,我需要結合使用這兩個日期。例如,如果我需要YTD收入,我需要選擇這樣的:MDX - 從另一個日期維度計算一個日期維度
(注:我寫SQL查詢,因爲我比較熟悉它)
SELECT Revenue
FROM
Fact_Revenue
WHERE
Invoice_Date <= '2011-10-22'
and AccountingCurrent >= '2011-01'
and AccountingCurrent <= '2011-10'
除了收入,這一事實表格還有其他我需要的信息,但是爲了計算這些其他數據,我不需要Accounting Current Date
。所以我的想法是在主MDX查詢中只使用1個日期(Invoice Date
)(這樣我就可以使用1個查詢獲取儘可能多的數據)並計算收入我想使用計算成員,並且在那裏我想聯繫Accounting Current Date
與選定的Invoice Date
。
例如
SELECT {[Measure].[RevenueYTD],
[Measure].[RevenueMTD],
[Measure].[NumberOfInvoices],
[Measure].[NumberOfPolicies]}
ON COLUMNS,
{[People].Members} ON ROWS
FROM [Cube]
WHERE
[Invoice Date].[Date Hierarchy].[Date].&[2011-10-22]
在這種情況下,[Measure].[RevenueYTD]
並[Measure].[RevenueMTD]
需要由Accounting Current Date
和Invoice Date
限於必須大於從查詢的時間低。在另一方面,我需要[Measure].[NumberOfInvoices]
和[Measure].[NumberOfPolicies]
爲particual發票日期(或MTD日期,等等),但沒有Accounting Current Date
計算成員的查詢應該做這樣的事情(這更像是算法)的involvemenet:
ROUND(
SUM(
YTD([Accounting Current Date].[Date Hierarchy].CurrentMember),
[Measures].[Revenue]
),
2)
WHERE [Invoice Current Date].[Date Hierarchy] < [Invoice Current Date].[Date Hierarchy].CurrentMember
不明白你介意改寫你的問題嗎? – ic3 2011-12-22 14:40:23
我編輯了我的問題。謝謝 – 2011-12-22 15:39:38