1
votes

I am new to ssrs .i am creating report which query on cube and provides the result i have used parameter for choosing to and from date and its giving error like "the restriction imposed by constrained flag is violated". what should i do ?i can not remove constrained because production server does not accepts mdx query without constrained. MDX Query is like this:-

select 
{[Measures].[Customers],[Measures].[Contacted Customers],
[Measures].[No of Bets],
[Measures].[Stakes GBP],
[Measures].[Turnover GBP],[Measures].[Signups]
} ON COLUMNS,
NON EMPTY{
[Date].[Calendar Date].[Date].allmembers
}
ON ROWS
FROM ( SELECT ( STRTOMEMBER(@mdxfromdate, CONSTRAINED) : 
STRTOMEMBER(@mdxtodate, CONSTRAINED) ) ON COLUMNS 
from [SportsWarehouse])
1
The documentation explains what can cause this error, although I don't know much about MDX so I can't tell you exactly what you should do. But since the error is caused if the member name cannot be directly resolved, what values do you have in @mdxfromdate and @mdxtodate and does your query execute if you put hard-coded values into it for testing?Pondlife

1 Answers

4
votes

The error is telling you that the value in @mdxfromdate isn't the name of a member. StrToMember() will not convert a generic date string to a member -- it needs to be something like:

[Date].[Calendar Date].[Date].&[19]

(to use an Adventure Works example), or whatever format the members of your Date hierarchy are in. If you want to only specify part of the fully-qualified name, you could build the name up dynamically as well:

StrToMember("[Date].[Calendar Date].[Date].&[" & @mdxfromdate & "]", CONSTRAINED)

Hope that helps.