Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default Values for Parameter not Working in SSRS 2008 R2

Tags:

I have a report (BIDS SSRS 2008 R2) that has a parameter that allows the user to select multiple values from a list (Sales Regions, lets say).

I want, though, since the list is long (15 or so possible values) have selected by default the 2 values that are used the most.

I configure that in the Parameter Properties >> Default Value dialog and when I run the report in preview mode it works, meaning, the default values are checked.

However, when I deploy it and run it with IE9 (or Chrome) it doesn't work.

Any ideas?

like image 841
Amarundo Avatar asked Sep 30 '13 20:09

Amarundo


People also ask

Can default values can be set for report parameters?

To add or change the default values for a report parameter If the Report Data pane is not visible, click View and then click Report Data. Click Default Values. Select a default option: To manually provide a value or list of values, click Specify values.

How does SSRS deal with multiple valued parameters?

Setting default values for multi-value parameters If we want to set Select All option as a default parameter we need to follow the steps below: Choose Get values from a query under the Default Values tab. Set HRReportParameterDataset into the Dataset Combobox. Set JobTitle field into the Value field.

How do you pass one parameter value to another parameter in SSRS?

To set available values for the second parameter In the Report Data pane, in the Parameters folder, right-click the first parameter, and then click Parameter Properties. In Name, verify that the name of the parameter is correct. Click Available Values. Click Get values from a query.


2 Answers

I would guess that your build is bad you are deploying and did not get updated from either a change you made or it is not overwriting a value. You can do a few things to ensure default parameter values are there.

  1. Go the published report on the server and click the drop down arrow on the right and choose 'manage'. Now choose 'Parameters' on the left pane. Under the 'Has Default' column (3rd from left on 2008R2 and higher) it should be checked. Then under 'Default Value' it is either a specific explicit input or it will say 'Query based' meaning it derives its value from a dataset or similar manner. If this is different than your value you would expect and is explicit you can just change it here.

  2. If it is query based and you observe that your data cannot be altered here I would go to BIDS and open up the SSRS project under the solution and choose to 'Open Folder in Windows Explorer'. Find your report's DATA file and delete it. Note this is NOT the report itself but a file similar to it like 'report.rdl.data'. This is NOT a step that most likely affects the build but merely the preview, however we wish to see the preview after the rebuild exactly as it would be. Go to your report's project and choose 'Clean' then 'Rebuild' to ensure you are removing all the data files in the bin in addition to the one you did explicitly. Rebuild will now build all the files from the instructions. Now click preview on your report, verify it is as expected with defaults. Publish again and observe.

  3. If this still did not change the report I would guess the updates are not taking. I would rename the report on the server like 'report_old' and try to publish again.

  4. If this still did not take I would check that the publish location we want is valid and we are deploying correctly and that any parameters are not getting data from shared datasets that are not set to 'do not overwrite' or weird edge cases resulting from publishing being halted due to config settings.

SSRS has had weird issues for me in the past with the issue of my files being under source control and then the system not wanting updates to parameters myself. Generally this is fixed with a rebuild but sometimes it does require a new binary file to be published.

like image 118
djangojazz Avatar answered Oct 16 '22 02:10

djangojazz


I saw the same thing this week, and it turned out to be because there were values in my multi-valued parameter's "default list" that were sometimes NOT in the data selection -- in my case, the default list's values were invalid for some dates I might select.

Here's what caught me: SSRS allows invalid values in the default list during development previews, but does not allow them in production.

In my example, the report was being developed in Report Builder. When I did a "Run" (a preview) of the report in Report Builder, the list parameter's checkboxes were selected for the default list's values, as designed. But when I saved the report, and ran it as a user would -- running the report from the Reporting Services browser page -- then no values were selected -- no defaults.

Then, to fix this, I took all selection criteria up to that point, and applied them to the default list -- making sure the "Default Values" only included values within the "Available Values" -- then the default values were selected, BOTH in Report Builder development, and in SSRS production.

EXAMPLE: assume my selection query for "Available Values" was:

SELECT Type
FROM MyTable
WHERE Date <= @BEG_DATE
  AND Date >= @END_DATE

And assume that, using 1/1/2013 and 12/31/2013 as dates, that the above returns 'A','B','C','X','Y','Z' as the list of values, for the user to select from (presented as checkboxes).

Now, assume that my selection query for "Default Values" was:

SELECT Type
FROM MyTable
WHERE Type IN ('A','B','G','H') 

The problem in this example would be that, for dates 1/1/2013 and 12/31/2013, the default values "G" and "H" are not valid values.

The fix in this example would be to add to the 'WHERE' clause, in the "Default Values" query. It becomes:

SELECT Type
FROM MyTable
WHERE Type IN ('A','B','G','H') 
  AND Date <= @BEG_DATE
  AND Date >= @END_DATE

Now, when this default values query is run for dates 1/1/2013 and 12/31/2013, the "G" and "H" drop out of the default values, and leaving only "A" and "B" as default values. "A" and "B" can both be selected, because they are also both in the Available Values for the parameter. So, defaulting the multivalued parameter now works, BOTH in development, and after saving the report (after deploying, after publishing) and running it from a browser.

like image 40
Doug_Ivison Avatar answered Oct 16 '22 03:10

Doug_Ivison