Tuesday, January 8, 2013

Get Current Date by MDX Query

NOW() is the function that gets you the current date. For example if you want to get a "measure" (let's say number of hours)  for the last year's months, then write something like:


select  [Measures].[Hrs] on 0,
Descendants(filter([D Date].[Hierarchy].[YEAR],[D Date].[year].currentmember.membervalue=YEAR(NOW())-1),[D Date].[Hierarchy].[MONTH],LEAVES) on 1
from [Cube]


Read in the following link for more examples on How To Obtain the Current Day with a MDX Query or Expression in SQL Server

No comments:

Post a Comment