How to query in mdx between two dates where the date is not exist in the cube

旧街凉风 提交于 2019-12-04 05:36:34

问题


i've some problem in query the data in mdx between two dates DateFrom and DateTo. simplely the problem is, assume we have 3 records of [Year][Month][Day]:

[2012][8][21]
[2012][8][22]
[2012][8][23]

if I pass the DateFrom and DateTo as something wasn't in the db, for example DateFrom = [2012].[8].[20] and DateTo = [2012].[8].[24], it show the error "Mondrian Error:MDX object '[Date].[2012].[8].[20]' not found in cube 'Email'"

but if i set DateFrom and DateTo as something in the db, for example DateFrom = [2012].[8].[21] and DateTo = [2012].[8].[23], it works.

because the DateFrom and DateTo was passed from the Frond end in web ui, so i can't contorl it, so i think i need to find the smallest value bigger than DateFrom and biggest value smaller than DateTo, But I don't how to, any idea? or do I have any other approach to solve this? thanks.


回答1:


In general, I suggest you to keep DateTime dimensions without holes and with a older bound in the past and a far away bound in the future, so you can query without problems.

If you cannot edit your cube definition, you may play around with FirstChild and LastChild operators in MDX to get start date and end date in you scenario (I suppose your dates are sorted).



来源:https://stackoverflow.com/questions/12049835/how-to-query-in-mdx-between-two-dates-where-the-date-is-not-exist-in-the-cube

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