0
votes

I have an MDX query that retrieves data from an SSAS 2005 cube:

SELECT NON EMPTY { [Measures].[Record Count] } ON COLUMNS
FROM [Cube]
WHERE { [Dimension].[Date].[Day].&[2012]&[1]&[1]:[Dimension].[Date].[Day].&[2012]&[1]&[10] }

This normally works well. However, when there are no records on 2012-01-01, it appears that a NULL value is substituted in and the query ignores that date range start parameter.

How can I check to see whether that dimension member exists and use another date (2012-01-02) in that range clause if it doesn't exist?

2

2 Answers

1
votes

Looks like this did it:

SELECT NON EMPTY { [Measures].[Record Count] } ON COLUMNS
FROM [Cube]
WHERE { IIF([Dimension].[Date].[Day].&[2012]&[1]&[1] IS NULL, [Dimension].[Date].[Day].&[2012]&[1]&[2], [Dimension].[Date].[Day].&[2012]&[1]&[1]):[Dimension].[Date].[Day].&[2012]&[1]&[10] }
0
votes

Does a subcube query have the same issue?

SELECT NON EMPTY { [Measures].[Record Count] } ON COLUMNS
FROM 
(SELECT [Dimension].[Date].[Day].&[2012]&[1]&[1]:[Dimension].[Date].[Day].&[2012]&[1]&[10]
ON COLUMNS FROM [Cube])