Friday, March 9, 2012

Dynamic default value for parameter in OLAP report

I'm trying to set up a parameter report from a OLAP cube. I need 3 dynamic parameters(ThisYear, ThisMonth, YESTERDAY).

THISYEAR: =CStr(DatePart("yyyy",Today()))

THISWEEK: =CSTR(DATEPART("ww",Today()))

YESTERDAY: =CSTR(Datepart("d", Today().AddDays(-1)))

So far so good. I want to send this report by email everyday, so I need to set these parameters as a default value. This is where I run into problems.

When I add any of these parameters I get the following error "The restrictions by the CONSTRAINED flag in the STRTOSET function were violated". This problem occur when I choose NON-queried under Report->Report Parameters, and set a default value for THISYEAR under DEFAULT VALUES

=CStr(DatePart("yyyy",Today()))

Hope someone found a way around this problem.

Thanks in advance!

It is because ASPNET user on the server machine does not have rights to access system date and time. On the report server, go to Control Panel -> Administrative Tools -> Local Security Policy and then select "Change the system time" and right click and select Properties. Then click on Add User or Group and add ServerName\ASPNET user to that list.

Also try this work around if you dont have access to the report server:

Create a new dataset called "DataSet2" and type the SQL text as SELECT GETDATE() AS CurrentDate

And use First(Fields!CurrentDate, "DataSet2") in place of Today() in your above default value expressions for parameters.

Shyam

|||I am using Reporting Services, so ASPNET user is not an issue here. I tried to create a new dataset, but I get an error that says that "Fields cannot be used in report parameter expressions". Any ideas?

No comments:

Post a Comment