I'm using MDX and Microsoft SQL Server 2008 Analysis Services. I have a Shipments cube with the following dimensions:
* Measures: Quantity
* Time: Year/Month/Day
* Ship Date: Year/Month/Day
* Receipt Date: Year/Month/Day
I want to know the quantity in transit on the last day of each month. How can I do that? In SQL, it would be something like this:
SELECT
A.[Month], SUM(B.[Quantity]) AS [In Transit]
FROM
( SELECT [Month], MAX([Day]) AS [End of Month] FROM [Time] GROUP BY [Month] ) A
CROSS JOIN
( SELECT [Quantity], [Ship Date], [Receipt Date] FROM [Shipments] ) B
WHERE
B.[Ship Date] <= A.[End of Month]
AND B.[Receipt Date] > A.[End of Month]
GROUP BY
A.[Month]