I am working on a SSRS Report and I have two Parameters in the Prompt section, EmployeeID and EmployeeName respectively.
EmployeeName prompt depends on the EmployeeID prompt selected, can the EmployeeName be populated in a textbox once EmployeeID is selected.
Right now EmployeeID is being shown in a drop-down and the user have to go to the drop-down and select it, can it be done in a textbox?
Any help would be greatly appreciated!
Create your main report dataset (dsMain for exmaple) with a query something like
SELECT * FROM myTable WHERE EmployeeID = #EmployeeID
I'm assuming you have the first parameter setup and working correctly to return your list EmployeeIDs. For this example we'll call this parameter EmployeeID/
Create another dataset (called for example, dsEmployeeName) with a query something like
SELECT EmployeeName from myEmployeeTable WHERE EmployeeID = #EmployeeID
In the second parameter (the one you want showing in a text box), leave the 'Available Values' blank and set the 'Default Values' to be from a query. Choose dsEmployeeName as the dataset and choose EmployeeName as the Value.
NOTE This will only work the first time round. If you choose another value from the drop down, the name will not be updated.
I don't know your exact requirements but if you can get both the ID and name together, why do you need two parameters, one of which does nothing really as it's not passed to the report?
Related
I am not sure if this is possible in Report Builder or not. I want to put a text box in a Report Builder report and then search the database for a specific person and display that in a subreport. Is this possible and, if so, how would you suggest I do it? I have tried researching it online without success.
This part will produce a parameter into which your user can type whatever they want
You need to set up your report to use parameters. You can set these parameters up to require user input either from manual entry or by picking from a pre-defined list.
Assuming you are returning your data using a SQL query, you can then reference these parameters in your dataset script. If for example you had a parameter called FirstName and another called Surname, and you only wanted to return values in your data set that matched both exactly, you would reference these parameters like so:
select PersonID
,FirstName
,Surname
,OtherDetails
from PersonTable
where FirstName = #FirstName
and Surname = #Surname
If you would rather have more of a 'search' type function, you can use the SQL like operator and wildcards, though bear in mind this will have a potentially very detrimental effect on your query performance:
select PersonID
,FirstName
,Surname
,OtherDetails
from PersonTable
where FirstName like '%'+#FirstName+'%'
and Surname like '%'+#Surname+'%'
This part shows you how to change that parameter so it provides a drop down menu. This part is optional.
If you want to provide a list of available options to select from, you can create a parameter that has a list of 'Available Values'. These can either be manually typed in by yourself - hard coding them in to the report design - or you can make them data driven by basing the parameter on a second dataset.
To get that list of people, you would want to return the ID of the person you are looking for as well as the details that are end-user friendly to be visible in the report:
-- select distinct so we have no duplicates
select distinct PersonID as Value -- Value is what is used to the query. This ideally will be a uniquye identifier
,FirstName
+ ' '
+ Surname as Label -- Label is what the user sees. This can be a bit more verbose and detailed
from PersonTable
order by Surname -- Specify how you want the options ordered
,FirstName
If you set this dataset as the source by selecting Get Values From A Query in the parameter options, you will see the drop down list appear when you run the report. Users can then select one, click Run Report and have their selection impact the data that is returned.
I have a report I need to develop where all Quotes should be listed where a specific Product is present. The product can be identified based on Product ID/Price/Product Name etc. I was looking to develop one report where all there fields are present as part of a dropdown. When the user selects one value such as Product ID and enters a value in the text box next to the ID, the report is filtered on this parameter. If the user selects name, the name can be entered in the text box and the report is filtered based on the Vendor ID etc.
Is there a way to do this? I have the parameters showing up next to each other instead.
It is doable if I understand correctly and here are the steps for achieving your report purpose.
I will use a simple query as an example data set for your reference.
1.Create source and datasets, in this example I skip the data sources and here is the short query for my exmaple
SELECT * FROM Table
WHERE
(ID = #ID or #ID = '')
and
(Name = #Name or #Name = '')
2.Add another dataset named Control, the query for Control is:
SELECT 'ID' as option
UNION
SELECT 'Name' as option
The purpose of creating this dataset is to provide the available values later when you need to choose either name or ID.
3.After step1, you should already have two parameters generated by system, which are ID and Name, if not, create them by yourself and go to each parameter page, DO MAKE SURE CHECK Allow blank value''
4.Create the 3rd parameter called Control, go to parameter setting page, go to Available Values, Choose Control dataset, Choose option (which is the customize column name you set in Controldataset) for both Value field and Label field
5.Go to ID parameter setting page, go to Default Values, choose Specify values, click fx, type this:
=Switch(Parameters!Control.Value="Name","")
Click ok
6.Go to Name parameter setting page, go to Default Values, choose Specify values, click fx, type this:
=Switch(Parameters!Control.Value="ID","")
Click ok
The ID and Name expression are correct, not set wrong
7.Change the parameter order to make Control on the VERY TOP, no matter ID or Name comes for the 2nd, but Control should be in the 1st place.
8.Drag and drop a table, place Name and ID. Preview the report, at this time, only Control will be available for you to choose value, choose either ID or Name to see the difference. When you choose ID, Name will be gray out, only ID light up and type any ID you want, actually, what the system does internally is passing the "" (blank value) to Name, that is why you need to make sure the Name parameter could accept blank value. Same for selecting Name
Update me if you have any run time issue
This is a simple question for someone with SSRS background. I am bit of a beginner to it and wondering when a report is generated, how do you get the drop down headers to appear on the report.
Say for example you got a column with username. Then you want to just select one username, i want a box at the top with username and a dropdown box appears, which then you can tick with the username?
Thank you
You can add a header onto the report and in the header add a text box. When you click into the expression of the text box and filter for parameters, you should be able to add any parameters you want to see on the report.
This will appear on all pages if in the header. Parameters can be placed anywhere on the report if that is not want you want.
You want to add a parameter. Here is an example of how to add a User select parameter:
Add a new Dataset to populate the parameter selection menu. Your query will be something like select distinct userid, username from YourTable order by username I typically name these Datasets something like DSUserSelect.
On the Report Data window, right click Parameters and select
Add Parameter...
Name your parameter User.
Under Available Values, select Get values from a query.
Select DSUserSelect (or whatever you named the Dataset in step 1) for the Dataset, userid for the Value, and username for the Label.
Update your Main Dataset query to include userid = #User in the Where clause. If your dataset is a stored procedure, you will need to add #User as a parameter to that stored procedure.
Let me know if I can provide any more detail.
I have run into a couple situations where I have a single report, but the user requires two ways to run it. For example, they want to either enter an employee id and pull up a single employee record, or they want to enter the company and department, or multiple companies and departments, and return employee records for all selected departments & comapnies.
I know how to do the cascading parameter thing, so I can do either way, but I dont want to have 2 reports, I would like to have one report with optional parameters. I envision two tabs or check boxes or soemthing when they first open the report, that say, "Click to view single record" and "Click to view multiple records" then which ever one they choose, they can enter the parameter(s) and run.
I have been researching and I am leaning towards sub reports and/or using ISNULL in the parameters and marking them as 'allow null'. STill playing with it, but if someone has a link to a nifty tutorial, I would be much obliged. Thanks.
What you can still squeeze comfortably out of SSRS:
A multi-value company parameter based on a dataset;
A cascaded (from company) multi-value department parameter based on its own dataset;
An optional multi-value employee id parameter, based on a dataset that might filter on company/department;
An optional custom employee id parameter, plain INT input;
Your datasets would be something as follows.
For #Company:
SELECT CompanyId, -- Param value
CompanyName -- Param display in SSRS
FROM vw_AllCompanies
And for #Department:
SELECT DepartmentId, -- Param value
DepartmentName, -- Param display in SSRS
FROM vw_AllDepartments
WHERE CompanyId = #CompanyId
And for #EmployeeId:
SELECT EmployeeId,
FullName
FROM vw_Employees
WHERE (DepartmentId = #DepartmentId AND CompanyId = #CompanyId)
OR (#DepartmentId IS NULL AND CompanyId = #CompanyId) -- Optional
Then your main dataset would do:
SELECT * -- Okay, don't use "*", but select actual columns :)
FROM vw_AllMyData
WHERE EmployeeId IN (#EmployeeId) -- The cascaded param
OR EmployeeId = #SomeCustomEmployeeId -- The custom INT input param
In my experience, this is slightly clunky, but probably the best you can get out of basic SSRS. If you want more flexibility I recommend you built something in your app around it, and pass the ID as a final parameter to the report.
I have two report parameters that were set up automatically when I created their associated datasets. They are ReportID and CompanyID. The user selects a Company Name from a list box and a Report Name from another list box. The standard SELECT ID, Name FROM TableName query was used to fill the respective list boxes. The report parameters work just fine and the report is displayed properly. My problem is this. I would like to place the selected Report Name and the Company Name in the report header (these are the Name values the user selected from the dropdown lists just before hitting the View Report button. I set up two new parameters, ReportName and CompanyName; marked them as hidden and set their default values to the appropriate datasets. The problem is that the header always shows the first name from the list, not the name the user selected. My question is, how do I place the selected information into the header?
I've had no problem doing this with the original set of parameters that are populated from a query.
In my reports I have a "Farm" parameter which is populated by a "SELECT FarmNumber, FarmName FROM Farms" query. The user selects the farm he wants from a ComboBox. I show the selected farm in the header of the report using this expression:
=Parameters!Farm.Label
"Label" is the "display text" (FarmName in this case) for the farm that the user selected.
Doesn't throwing in Parameters!ReportID.Value into a textbox in the header work?
From what it sounds like, you should use whatever the original Parameter is named in the 'ReportID' spot.
With SSRS 2008 R2, I had a header with multiple parameters:
My Export for [#ReportDate] [#AccountId.Label]
If CompanyID is a multi-value parameter, this will work:
=Join(Parameters!CompanyIDs.Label,System.Environment.NewLine)
=Parameters!Farm.value
replace value with Label
=Parameters!Farm.Label