如何在多维数据集中不存在日期的两个日期之间查询mdx [英] How to query in mdx between two dates where the date is not exist in the cube

查看:139
本文介绍了如何在多维数据集中不存在日期的两个日期之间查询mdx的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在查询两个日期DateFrom和DateTo之间的mdx中的数据时遇到了一些问题.简单来说,问题是,假设我们有3条[年] [月] [日]的记录:

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]

如果我将DateFrom和DateTo传递为数据库中未包含的内容(例如DateFrom = [2012].[8].[20] and DateTo = [2012].[8].[24]),则会显示错误"Mondrian Error:MDX对象'[Date].[2012].[8].[20]". ]'在多维数据集电子邮件"中找不到"

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'"

但是如果我在数据库中将DateFrom和DateTo设置为某些内容,例如DateFrom = [2012].[8].[21] and DateTo = [2012].[8].[23],它将起作用.

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.

因为DateFrom和DateTo是从Web ui的Frond端传递过来的,所以我无法控制它,所以我认为我需要找到大于DateFrom的最小值和小于DateTo的最大值,但是我没有怎么做,有什么想法吗?还是我有其他解决方法?谢谢.

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.

推荐答案

通常,我建议您保持DateTime的尺寸没有空洞,并且在过去有一个较旧的界限,而在将来则有一个较远的界限,因此您可以查询没有问题.

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.

如果您不能编辑多维数据集定义,则可以在MDX中使用FirstChild和LastChild运算符来获取方案中的开始日期和结束日期(我想您的日期已排序).

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).

这篇关于如何在多维数据集中不存在日期的两个日期之间查询mdx的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆