Elvis Lou
Elvis Lou

Reputation: 172

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

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.

Upvotes: 0

Views: 1157

Answers (1)

michele
michele

Reputation: 2091

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

Upvotes: 1

Related Questions