I'm using SSRS 2008 R2 and i'm trying to set a Report manager default parameter.
I can set a parameter at run time i.e. '02/03/2006', or assign a drop down boxes via a query but i need it to have a variable date range
I've tried using:
=getdate()
getdate()
now()
=now()
....the list goes on
Thanks for your help,
Jim
SSRS Report Manager doesn't support using a formula as the default value for a parameter except for when the formula is specified as the default value in the report definition itself.
You should edit the .rdl file in Business Intelligence Development Studio and set the default parameter value there.
Related
We are running Power BI Report Server Sept 2022.
I have a SSRS "Dashboard" report that uses multiple parameters to create "Go to URL" actions for various jumping points in my report.
#PowerBIReportServer is set to Default Value, Specify value of "/Reports/powerbi"
#SSRSReportServer is set to Default Value, Specify value of "/Reports/report"
Then I use these in other parameters like:
#PowerBIHelpReport is set to Default Value, Specify value of:
="javascript:void(window.open('" + Parameters!PowerBIReportServer.Value + "/General%20Reporting%20Help" + "','_blank'))"
Then I have a help button that has the Action\Go to URL set to [#PowerBIHelpReport].
When I preview the report on my developer PC I correctly see that #PowerBIHelpReport:
javascript:void(window.open('/Reports/powerbi/General%20Reporting%20Help','_blank'))
But, when I deploy this to the report server the value changes to this and if I click the link I get a folder listing:
javascript:void(window.open('/ReportServer/General%20Reporting%20Help','_blank'))
I also see that the parameters #PowerBIReportServer and #SSRSReportServer both have a value of "/ReportServer"
What's going on?
I saw this question\answer:
SSRS 2008 Rpt Bldr 3: Go to URL action not setting parameters
But if "ReportServer" is what's needed in the URL, how do I point to the different report types: SSRS vs Power BI?
So two things resulted in me getting this to work.
Changed **#PowerBIReportServer** to: =REPLACE(Globals!ReportServerUrl, "ReportServer","Reports/PowerBI")
Changed **#SSRSReportServer** to: =Globals!ReportServerUrl + "?"
This link helped me arrive at this solution for the SSRS parameter.
https://community.powerbi.com/t5/Report-Server/Link-to-another-report-using-Built-in-Collections-global/td-p/1645567
In SSRS, a Date Time parameter on Preview is not matching the deployed report. Is this something someone else has encountered? The RDL code is identical. Is it the fact that, sometimes, a local preview is just a simulation of functionality? Is it because the display in preview sometimes uses cached data?
I have a SSRS report that, when I preview it in Visual Studio locally, the date shows as 2/10/2019 but when the RDL code is deployed on the server, the date shows as 2/7/2019.
The date time variable is based on a parameter on the report, called rundate, and it has a Default Value of 2/10/2019.
So I think the same thing should happen on the Report Server that happens locally in preview mode.
The report has four datasets and, as a test, I have set each four to have the SQL line that sets the rundate value like so:
SET #rundate = '2019-02-10'
but on the report server, when I load the report, it throws this error:
Must declare the scalar variable "#rundate". Must declare the scalar variable "#rundate".
It is in a cascading tabbed error message that looks like this:
An error occurred during client rendering.
An error has occurred during report processing.
Query execution failed for dataset 'ThirdDataset.
Must declare the scalar variable "#rundate". Must declare the scalar variable "#rundate".
So, why does it run locally and not on the server? The "ThirdDataset" is a false name I have given here. The actual name is redacted. But, I have noticed that this would be the first dataset run if they are run alphabetically. So this leads me to the question: why doesn't the report recognize this as a parameter and why does it complain that it is not declared?
============
UPDATE:
I have set the rundate to be part of a data-driven subscription in a report like so:
SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate
Which is two days ago. Since it is 2/11/2019 today, the rundate parameter passed to the SSRS report on the server should be 2/9/2019.
For fun, to test this out, I set the Default Value rundate parameter to be 8/8/2018 in hopes that the data-driven report would set it properly.
In preview mode locally on Visual Studio, a textbox that set to show the [#rundate] Expression shows 8/8/2018 which is what I would expect, but the Datasets are designed to run off this parameter. Since there is nothing that the sql should retrieve from the database that is that old, the graphs and charts in preview mode should turn up completely empty. Why do they show data?!
Next, let's see what the emailed subscription alert says. It had the date of 2/11/2019 12:00:00 AM. If the data-driven subscription ran like it shouold ahve run, it should of had the date of 2/9/2019 from
SELECT convert (date, DATEADD (DAY, -2 , SYSDATETIME())) as rundate
Why did this not work?
On the SSRS server, the RDL file has a parameter default value of 2/11/2019 12:00:00 AM but why did the report get THIS default value? What am I doing wrong and how can I fix this?
As a test, I set this default date/time parameter to 12:12:34 for its time to see what would happen. It reveiled that, yes, this is the date time stamp that is being sent to the report. So I unchecked the "Has Default" box
Then, I noticed in the Step 5 of the data-driven subscription I could not advance to Next > without making a small change:
So, what should happen? Will it show the wacky 8/8/2018 value? Will it show the date from two days ago?
Default values for report parameters are deployed only once to the report server, and then they keep their default value after subsequent deployments. This is so that default parameter values used in development don't overwrite the desired parameter defaults on the production server.
So it looks like when the report was first deployed, #rundate had the default value 2/7/2019 but has since been changed on the local report to 2/10/2019. Go into your report server, find the report and go into the Report Parameters section to edit the parameters and change the default value to what you want it to be (deleting the report from the report server and re-deploying it with the updated parameter will have the same effect, but note that the parameter will maintain that default value going forwards). Alternatively, set the report parameter using an expression so that it is continually up to date.
Regarding updating your parameter value in the Sql statement using the SET statement, you can't actually do it that way - you need to set it in the report's parameter list so that SSRS can set the parameter value. Consequently, your databse server is complaining that you are trying to set the value of a local variable that hasn't been defined in your Sql statement, and thus throws an error message.
So you need to set up the Report Parameters in the report parameters section in the report designer. Your Sql can then reference your parameters like so:
SELECT * FROM MyTable WHERE SomeDate >= #rundate
The parameters normally get mapped into your dataset automatically but you might want to check this by going into the Parameters settings on your dataset to make sure. If the parameter doesn't exist there, set it up.
After lengthy trial and error, I found that the answer was to NOT have the parameter set to have a default value on the SSRS Report Server.
I am using an expression to calculate a default value for the parameter, Year, in SSRS 2016
=DatePart("YYYY", DateAdd("YYYY", -1, Today()))
When I run a report on a one-off basis, the parameter populates. However, when I try to configure an email subscription and choose to have the parameter populated by using the Default Value, I am presented with an error that reads
An error has occurred.
This report requires a default or user-defined value for the report parameter 'Year'. To run or subscribe to this report, you must provide a parameter value.
Is my expression not configured correctly? It seems unlikely as the report performs as expected when run manually.
#Tony D's comment put me on the path to the answer. The report had to be deleted from and re-added to the server to clear the cache. After doing this, the parameter filled as expected. I found this suggestion here. Thank you, Tony!
I have a SSRS report parameter that is incorrectly defaulting to NULL (All), when I have the 'No default value' option selected. The parameter uses a stored procedure to load available values, and there are several values in my parameter drop-down-box.
When I view my report in preview mode or on the SSRS poral, my parameter is automatically set to All (NULL). What would make this happen?
The XML code shows no default values either:
<ReportParameters>
<ReportParameter Name="[My Parameter Name]">
<DataType>Integer</DataType>
<Nullable>true</Nullable>
<Prompt>My Parameter</Prompt>
<ValidValues>
<DataSetReference>
<DataSetName>MyDataSet</DataSetName>
<ValueField>MyParameterID</ValueField>
<LabelField>MyParameterName</LabelField>
</DataSetReference>
</ValidValues>
</ReportParameter>
As some users stated in the comments, you must delete and redeploy the report to update parameter defaults. According to Microsoft this is a known issue:
Parameter defaults do not get updated when re-deploying existing
reports. These either have to be updated manually or the reports
deleted and re-deployed. The latter regenerates all report ID's
(GUID's) and makes traking usage from the ExecutionLog more difficult.
I have a date range parameter(s) in a report. The query has in the where clause:
BETWEEN #StartDate AND #EndDate
and in the report, these parameters exist, and set to DateTime datatype. #Startdate has a default hardcoded as 1/1/1900 12:00:00 AM. I tried using =Today() for the #EndDate, and it works in BIDS, but gets to the report server as no default. I also tried creating a report variable, and setting the default to that, but go an error stating I can't set parameter defaults to report variables.
So, how do I get my #Enddate to default to today's date in the report server?
Try deleting and deploying the report from the report server; sounds like it's not recognizing some of your changed properties. Should that not work, view the report in Report Manager, and go into the management/properties page on it - you should be able to see (and, if necessary, set) the default value.
I tried that, no help. I ended up creating a new dataset with a simple query to get todays date (GETDATE), then set that as the parameter default. Works like a charm.