I'm using SSRS 2008R2 and i try to get single value from dataset to use it as default value of report's parameter.
Dataset filled with this query:
select distinct
o.organization_id,
o.mean_name,
o.short_name
from
dbo.organization o
inner join
dbo.identifier i on i.organization_id = o.organization_id and
i.market <> 3
I have report's parameter organization_id, whose value user selects. And now I want get value of field short_name from dataset where field organization_id equal to parameter organization_id. But I can't do this.
I tried to use Lookup function like this:
=Lookup(Fields!organization_id.Value, Parameters!organization_id.Value, Fields!short_name.Value, "dsOrganizations"), but server gave me error "Fields cannot be used in report parameter expressions".
I tried to make variable with this Lookup function, but variables can't be used in report parameters.
And now I have no idea how set parameter default value from dataset.
I will welcome any tips or suggestions.
I create one more dataset with this query: select short_name from organization where organization_id = #organization_id and set parameter value equals to parameter organization_id. After there I set default value to parameter short_name just as "Get values from a query" and as dataset set new dataset.
I hope, that my experience will be useful to someone.
Related
My current definitions for this report are like this:
DataSet A = a pretty extensive query with 'AND ai.Channel IN (#ChannelParameter)'
DataSet B = Channel 'Select distinct channel from Account_Info'
result set 'Retail Channel' or 'Wholesale'
Parameter = #ChannelParameter is set to Allow Multiple Values and is Getting the values from Query.
Tablix Properties - Filters
Expression [Channel]
Operator IN
Value =Parameters!ChannelParameter.Value(0)
When I run the report and select 'Retail Channel', I get the correct data.
When I run the report and select 'Wholesale', I get the correct data.
When I run the report and select both values, I get zero rows returned.
When I modify the query for DataSet A to be ai.Channel IN ('Retail Channel','Wholesale'), I get all of the rows. There are no rows in the data where the Channel field is NULL.
I've seen and tried some changes to the expression in the parameter using a JOIN statement, but no better results there.
What am I missing?
You filter expression is incorrect, as you stated (0) that means only the first parameter value will be used.
Having said that, it looks like you are already filtering the data in your A dataset so there is no need for the tablix filter, just remove it.
I would like to know if it is possible in report manager to give a specific linked report a "Select all" as default for a parameter.
Here is where i want to set the parameter to select all:
in Report Builder or Visual Studio:
create the parameter query like:
select null as value, '<ALL>' as label
union all
select distinct value, label from xxxxxxxx
this will return the values with specific row on the top.
now in your dataset where clause you can set the following and it will return all or whatever is selected:
XXXXX=CASE WHEN #parameter IS NULL THEN XXXXX ELSE #parameter END
set the XXXXX to the column that provides the parameter info, make sure you set the parameter to accept null values.
Then all you have to do in SSRS is pass null into that parameter
set the default value as 'NULL' in the parameter
There is probably a different, easier way but it works for me.
In order to do something like this, you will have to provide a list of possible values for the parameter. This can be done either by using the Specify values in the Available Values, or the Get values from a query option, in the parameter properties.
This is done in the report designer, or Report Builder. It cannot be done reliably via Report Manager (like in your screen capture).
Once you have that in place, make sure the default values for the parameter are set to all available values.
I have a report with several parameters, all in varying degrees depending on the value of its predecessors. I’m trying to convert from single selects to multi-selects. I’ve set the multiselect values for Report Type – see image – and would like to set the default value for the multiselect Jobs Type parameter. The logic would be: ‘If Jobs is not selected in Report Type, set ‘NA’ as default. If Jobs is selected, display the list of job types’. The job type dataset is used as the Available
Values list. I have a defaultJobType dataset with the following code:
IF 3 IN (#ReportType)
SELECT 0 as JobTypeId, 'N/A' as JobTypeDesc
Is there any way to accomplish this goal?
Create a DataSet to get "Default JobType" based on report type as per your requirement
like as you said IF 3 IN (#ReportType) SELECT 0 as JobTypeId, 'N/A' as JobTypeDesc
create a SP (stored procedure or query with parameter report type)
as we normally do for Cascading Parameters ...
once its done then set the default value of Job Type Parameter ,
1. select option "Get value from a query"
2. Choose DataSet which created to get Jobtype based on
3. set value field JobTypeId
you can also say that, there are two data set to populate Job Type one for populating drop down & another for select Default value...
SSRS parameter only returns the first name in list.
I am running SQL Server 2008 (NOT R2) Reporting Services
I have a Parameter called #Signature in my Dataset. The query for this parameter pulls a list of names from a field called “fullname.”
The properties of the parameter are “Get values from a query” and the Available Values are set to
Dataset = Signature
Value Field = fullname
Label field = fullname
I placed the “fullname” field in my report, but when I select any name from the list in my parameter, it always returns the first value in the parameter list. I am pretty certain that is because the expression for this field is set to the following: =First(Fields!fullname.Value, "Signature") Because I have 2 datasets, I have to distinquish with “Signature.”
I need the “fullname” field to populate with the name I select in my parameter.
If you want to display the name selected in your parameter, use the expression:
=Parameters!Signature.Label
I have to set the start_date of my report depending of a report parameter. The time stamps are calculated in a database query.
My expression looks like this:
=SWITCH (
Parameters!report_type.Value = 1,First(Fields!daily_start.Value, "Timestamps")
,Parameters!report_type.Value = 2,First(Fields!weekly_start.Value, "Timestamps")
,Parameters!report_type.Value = 3,First(Fields!monthly_start.Value, "Timestamps")
)
Unfortunately I get the error message:
A value expression used for the report parameter 'time_from' refers to a field. Fields cannot be used in report parameter expression
I know, that this is not allowed because SSRS cannot be sure in which order datasets are called. But I think this is not dangerous.
All time stamps are received by query without parameter. The parameter report_type is selected by a user before the report will be generated.
Can someone give me a hint for a workaround?
Here's the workaround - get the value using SQL.
Create a new Dataset called StartDates:
SELECT CASE
WHEN #report_type = 1 THEN daily_start
WHEN #report_type = 2 THEN weekly_start
WHEN #report_type = 3 THEN monthly_start
END AS StartDate
FROM MyTable
You already have the #report_type and #time_from parameters. With the #time_from parameter, set its Default Values to Get values from a query using the StartDates dataset and the Value field StartDate.
Now, you'd think this might be enough to make it work - you're referencing this query as the default value and as you change the #report_type parameter the other parameters refresh, but the first date in the #time_from parameter never changes. That's because the refresh happens on the Available Values query, not on the Default Values query.
So you also need to wire up the Available Values query to the StartDates query. Now your query will fire on the change of #report_type and the default value will be set to the appropriate date for your selection.
I switched from a query to Stored Procedure and was getting this error. Things I tried:
Ensured I had sufficient permission on the database (you need EXEC rights or DBO to run teh sproc)
Delete the existing parameters (and then use refresh fields to refresh/get the correctly named ones back)
Remove the square brackets around the stored procedure if you've specified that
Sometimes, Expressions can get a bit verbose. I have created a Report Code Function and then used that as the Parameter Value.
For example, I created a Code function called "CalculateDateSet" and then set the Report Parameter to this expression:
"=Code.CalculateDateSet(Parameters!Month.Value, Parameters!Year.Value"