问题
I have little thing about MDX. Is there any way to get current year from the system/server with MDX query? I didn't have any dimension related to date or something like that.
Regards.
回答1:
Create a member and define it as 'YEAR(NOW())'
Member [Measures].[Current Year] as 'YEAR(NOW())'
Here is a more complete sample
-- The First Calculated member is the value of NOW()
WITH MEMBER [Measures].[Full Date] as 'NOW()'
-- The Second Calculated Member is the Day part of the first calculated member.
MEMBER [Measures].[What Day] as 'DAY([Full Date])'
-- The Third Calculated Member is the Month part of the first calculated member.
MEMBER [Measures].[What Month] as 'MONTH([Full Date])'
-- The Fourth Calculated Member is the Year part of the first calculated member.
Member [Measures].[What Year] as 'YEAR([Full Date])'
SELECT
{[Full Date],[What Day],[What Month],[What Year]} ON COLUMNS
FROM [Your Cube]
来源:https://stackoverflow.com/questions/13371904/how-to-get-current-year-with-mdx-query