Building on a previous question, I am trying to achieve the following result set to use in an SSRS 2008 report.
Utilisation New Measure
Apr-12 70.7% 70.7%
May-12 74.5% 74.5%
Jun-12 74.6% 74.6%
Jul-12 76.7% 76.7%
Aug-12 79.5% 79.5%
Sep-12 78.5% (null)
Oct-12 79.0% (null)
Nov-12 79.6% (null)
Dec-12 78.9% (null)
Jan-13 79.7% (null)
Feb-13 79.0% (null)
Mar-13 79.4% (null)
The MDX query I have so far is as follows:
WITH MEMBER [Measures].[New Measure]
AS IIF(
ISEMPTY(
EXISTS(
[Date].[Fiscal Year-Month].[Fiscal Month].CurrentMember
, {[Date].[Fiscal Year-Month].[Fiscal Month].&[2012/13]&[1]
:[Date].[Fiscal Year-Month].[Fiscal Month].&[2012/13]&[5]}
)
)
, NULL
, [Measures].[Utilisation]
)
, FORMAT_STRING = "0.0%"
SELECT {
[Date].[Fiscal Year-Month].[2012/13].children
} ON ROWS
,
{
[Measures].[Utilisation]
, [Measures].[New Measure]
} ON COLUMNS
FROM [Elective]
Though the New Measure returns the same results as the utilisation measure and does not return Nulls for the months I don't want the values for.
You're close but don't have the syntax quite right. Try this:
WITH MEMBER [Measures].[New Measure]
AS IIF(
EXISTS(
{[Date].[Fiscal Year-Month].[Fiscal Month].&[2012/13]&[1]
:[Date].[Fiscal Year-Month].[Fiscal Month].&[2012/13]&[5]},
[Date].[Fiscal Year-Month].[Fiscal Month].CurrentMember
).Count = 1
, [Measures].[Utilisation]
, NULL
)
, FORMAT_STRING = "0.0%"
SELECT {
[Date].[Fiscal Year-Month].[2012/13].children
} ON ROWS
,
{
[Measures].[Utilisation]
, [Measures].[New Measure]
} ON COLUMNS
FROM [Elective]
With the EXISTS function, the first argument is the full set to check - the date range you want values to display for - and the second argument is the current member on rows, so you need to do the opposite of what you originally tried. The EXISTS function returns a set, so you can use the COUNT function to see if the set has something (the current member), which should be only 1 when there is a match. The reason the ISEMPTY is not working for you is that the MDX is including the current measure in the calculation and when the value exists for the current date member and the Utilisation measure, the expression resolves as false and returns Utilisation.