how to get latest date in mdx?

微笑、不失礼 提交于 2020-01-06 04:46:04

问题


if i pass my mdx like this i am get what i am expecting..

With
Set [TimeLimit] as 
 '{([CurrDate].[All CurrDate].[2010].[Q3].[Jul].[2010-07-21])}'
select 
 NON EMPTY {[Measures].[Balance], [Measures].[Peso Equiv]} ON COLUMNS,
 NON EMPTY {
  [PARTICULARS].[All Particulars], 
  [PARTICULARS].[All Particulars].[RESIDENTS], 
  [PARTICULARS].[All Particulars].[NON-RESIDENTS]
 } ON ROWS
from [depositlib_22]
where ([TimeLimit])"

Question?:- i dont want hardcode this part "[2010].[Q3].[Jul].[2010-07-21]",i need to get date from my cube(cube always geting latest date from database table).

let me know any one how we can possible to get?

pls,help us on this i am trying past 2 days...still unable to fondout solution.

Thanking u in advace...


回答1:


You have two ways to deal with date issues like this in MDX. One is to use a VBA date function to build a string using the date you want. If you make this string match the member name in your dimension you can then convert it into a set. See Sql Analysis Services Current Date

The second way, which I think you need to look at, is to use MDX functions to find out which is the last (i.e. most recent) member in your [CurrDate] dimension. You can then use that member in your query. This will work fine as long as your dimension contains only dates in the past. I once implemented this idea and then found a future date of 2015 crept in the cube by accident, and then my MDX didn't show me todays date (which was usually the most recent member).

The set you need might be:
{[CurrDate].[Date].members.Item([CurrDate].[Date].members.count-1)}
Or the equally un-elegant:
{[CurrDate].lastChild.lastChild.lastChild.lastChild.lastChild}



来源:https://stackoverflow.com/questions/3536359/how-to-get-latest-date-in-mdx

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