SSAS FAQ MDX FAQ MDX-Query to get latest months and previous years same months data
MDX-Query to get latest months and previous years same months data
User Rating: / 0
PoorBest 
Written by Vidas Matelis   
Tuesday, 03 April 2007 19:37

Q: Need MDX Query to get latest months and previous years same months data

A: You can use ClosingPeriod function to get last month member and then use ParallelPeriod function to get previous years same month

SELECT {ClosingPeriod([Date].[Calendar].[Month], [Date].[Calendar].DefaultMember)
, ParallelPeriod([Date].[Calendar].[Calendar Year]
, 1
, ClosingPeriod([Date].[Calendar].[Month], [Date].[Calendar].DefaultMember)
)
} ON 0
FROM [Sales Summary]

Result:

August 2004 August 2003
(null) $5,060,385.02

 
Comments (2)
2 Wednesday, 13 August 2008 18:48
admin
I have not seen dynamic MDX language tutorial anywere and I do not believe it exists.
To run sample code you have to instal Analysis Services, then download and install Adventure Works database, deploy this sample solution and then you'll be able to run MDX queries.

To install Adventure Works DW database follow this link:
http://www.ssas-info.com/analysis-services-faq/29-mgmt/242-how-install-adventure-works-dw-database-analysis-services-2005-sample-database
1 Wednesday, 13 August 2008 18:43
Virgilio
Is there a dynamic tutorial where I can run MDX queries
(like GalaXQL).
It seems that the only way to practice is having BIDS and still you will need a datasource cube to run queires against.

Is there another way?
Strategy Companion