How to Get Current Year with MDX Query?

痞子三分冷 提交于 2020-02-07 08:21:05

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!