In SSRS, how can input multiple data into text box? - reporting-services

I'm trying to construct a report in SSRS and I would like to know if instead of using a multiple selection drop down box to search for a particular set of serial numbers, I can give users the ability to manually enter multiple serial numbers of their choice into a text box.
The list of serial numbers in the particular data set is quite large, so with a drop down user would be scrolling through thousands of serial numbers, as opposed to just typing in serial numbers of interest.

You can do this using a parameter
Add Parameter
In the general properties amend the data type and check Allow Multiple values
Click OK
Right click on your data set query
Left click DataSet Properties
Left click Parameters
Add the parameter you created in 1 above - preceded by #
Click on fx
in the expression dialog key =SPLIT(JOIN(Parameters!.Value,","),",")
Click OK
Click OK
Amend your dataset query to include where something in(#)
Save the amended query
Preview the report
A parameter box will appear
Click on the drop down
Enter a comma separated list of serial numbers
Click on view report
Using adventureworks added a parameter #soid
The split statement is
=SPLIT(JOIN(Parameters!SOID.Value,","),",")
The dataset query is
SELECT SalesOrderID, RevisionNumber, OrderDate, DueDate, ShipDate, Status, n OnlineOrderFlag, SalesOrderNumber, PurchaseOrderNumber, AccountNumber, CustomerID, SalesPersonID, TerritoryID, BillToAddressID, ShipToAddressID, ShipMethodID, CreditCardID, CreditCardApprovalCode, CurrencyRateID, SubTotal, TaxAmt, Freight, TotalDue, Comment, rowguid, ModifiedDate
FROM Sales.SalesOrderHeader WHERE SalesOrderID in (#SOID)

Related

SSRS dropdown with progressive search

Is there a way to make a dropdown in SSRS limit what is shown as a value is typed. As it currently is it just goes to the first item starting with the letter, but in a big list, this still means a lot of scrolling to get to the desired value. This specific report is on SQL Server 2019, but if there is a way to do it for 2016 as well that would be nice to update some of the reports on older servers
Thanks
As far as I know there is no way to do this directly. However, you can do this with some compromise.
Let's say I have a long list of customers that I want to filter.
I create a dataset (dsCustomers) with a dataset query something like
SELECT * FROM customers
I have a parameter which uses this dataset as it's list of available values called pCustomer
If I want to be able to filter this list I would add a new parameter called, say, pCustSearch. This will be a simple parameter with no associated dataset. You can optionally allow NULL values.
Now I can change the dataset query for dsCustomers to be
SELECT *
FROM customers
WHERE (Customername like '%' + #pCustSearch + '%'
OR
#pCustSearch ISNULL)
NOTE: The pCustSearch parameter must be the first parameter (or at least before the pCustomer parameter)
Once you have filled in the search parameter and tab to the main customer drop down, it should filter the values that match what you have typed.

Report Builder 3.0 - permit user to add data in after report generated

Using Report Builder 3.0 against cubes which are produced overnight.
The report I'm designing is used to archive or transfer (physical) files for patients. Users run the report, print it & then attach it to files that are then sent to a central area which will archive/send the files on.
The report has a number of parameters which is designed to return a single patient. This all works fine.
One of the parameters (#prmReason) is a single choice on what is to happen to the files, eg, "Transfer" (transfer files to another office), "Archive - closed", "Archive - deceased", "Archive - excess" (office space is limited, so staff archive off 'older' files).
One of the fields returned is CloseReason. This field always has a value. If the field is empty in the database (as the client hasn't closed), then it will contain the value: "Unknown".
This field (amongst others) are either displayed or hidden, depending on #prmReason. Again - all working without a problem.
Now for the tricky bit.
If the #prmReason = "Archive - closed" or "Archive - deceased" then the report will display CloseReason.
The problem is if CloseReason = "Unknown" then I need to know the why the file is closed & display it on the report.
I want users to be able to choose a value from a list of closure reasons. I then want the choice to be displayed on the report. Obviously if there is a genuine reason then display this value.
So the effect I'm after is:
User selects parameters & runs report.
Report then checks to see why report is being run (eg #prmReason).
If #prmReason =("Archive - closed" OR "Archive - deceased") AND CloseReason = "Unknown"
Then somehow produce a list of CloseReasons that the user can select. This value is then displayed on the report.
I can even cope with it being a free text field. Just something so that the central area can update the database if necessary & save a phone call/email etc.
(Yes, I realise that I can have the list as a series of tickboxes that the user ticks after the report is printed, but this would be a useful ability in other reports).
EDIT: empty value of CloseReasons conflicted with stackoverflow formatting (sorry didn't review post properly). Value is actually less then symbol then the word Unknown and then greater than symbol. It doesn't really affect the problem
You could add an additional hidden parameter.
If this parameter is not set then display an small table on your report that has a list of CloseReasons.
You then set table cell's action property to open the a report, choose your existing report as the report to open but this time you can pass a value for the final parameter, which, as well as displaying the Close reason in your report, would also hide the close reason choices table described above.
UPDATE To make clear more clear.
The following is based on the Northwind sample database. I have a shared data source pointing to this database.
Create new report.
Add a data source pointing to the shared Northwind data source
Add a new data set pointing to the data source above with the following query
SELECT
EmployeeID,
FirstName, LastName, Address, City, Country, Title, Notes
FROM Employees
WHERE EmployeeID = #EmployeeID
Add some of the fields to the report to show some basic info.
We now have a simple report with a single parameter #EmployeeID
Next we want to show some actions for each employee. For flexibility, I'm making this list dynamic based on the employee's Country. This list could be static.
Create a new dataset dsActions with the following query
DECLARE #actions TABLE(ActionID int, ActionLabel varchar(20))
-- Get employees country
DECLARE #Country varchar(20) = (SELECT Country FROM Employees WHERE EmployeeID = #EmployeeID)
IF #Country = 'UK'
BEGIN
INSERT INTO #actions VALUES
(1,'Sack them'),
(2,'Buy them a pint'),
(3,'Promote')
END
ELSE
BEGIN
INSERT INTO #actions VALUES
(1,'Fire them'),
(2,'High 5 them'),
(3,'Ask them to run for office')
END
SELECT * FROM #actions
Add a table to the report to show these values.
At the moment my design looks like this. (All the expressions are simple fields from the first dataset to show the employee details, nothing special)
And when I run it I get this.
OK, now all the basics are done, we need to be able to call this report again, but with an action already chosen. We'll make the actions table clickable and pass the action's label to the report.
It's the same report, we will only ever have a single report.
First, add a new parameter called action to the report and make it hidden. Add a default value of 'noaction'.
Next we want to only show our actions table if the action parameter is set to 'noaction'. To do this, set the Hidden property of the action table (tablix) to the following
=Parameters!action.Value <> "noaction"
Next we want to add a text box that displays the result action parameter, but only when the action parameter is not noaction.
So add a text, set it's expression to =Parameters!action.Value and the hidden property to =Parameters!action.Value = "noaction"
Finally, we need to make our actions list call our report but with a specific action. To do this we need to modify the actions table.
First save the report, whatever name you choose is the name you will select as the target report as the report will call itself.
Right-click the cell that contains the ActionLabel and go to the text box properties.
Select the Action tab and then choose "Go to report". Choose the name of the report you are currently working on (this actual report as the report will call itself).
Set EmployeeID parameter to [#EmployeeID] and the action parameter to [ActionLabel]
I've used the label for simplicity but you could pass the ActionID as long as you account for this in the text box that displays the action.
Optionally you could format the text so it looks like a link,
The final design and action/parameter setup looks like this
When I first run the report I get the following...
As soon as I click one of the actions, I then get this...
Hopefully that's clear now.

Single Parameter Multiple Queries in MS Access

I have a base Query that pulls in data to be used in multiple queries.
Select
ClientActivities.FacilityID
,Facility.FacilityName
,ClientActivities.ClientID
,ClientActivities.ActivityID
,ClientActivities.ActivityDate
From
ClientActivities
Inner Join
Facility
on
ClientActivities.FacilityID = FAcility.FacilityID
Where
ClientActivities.ActivityDate Between [StartDate] and [EndDate]
This feeds two other Queries.
Select
FacilityName
,Count(ClientID)
From
BaseQuery
and
Select
ActivityID
,Count(ClientID)
From
BaseQuery
When I put them both on a single report as subreports- it asks me for the StartDate and EndDate twice. I would like for it to ask only once. Any suggestions on how this can be done? While keeping it simple as once I turn this over to the user I will be leaving and the extent of their Access training is one college class.
Thanks,
Set up a form to run the report from...
Create a form named "frmReports" that contains two text boxes and a button.
Name the text boxes "txtStartDate" and "txtEndDate".
In the queries, put the fully qualified names of the text boxes on the form into the criteria section of the queries. For example: Forms![frmReports]![txtStartDate] and Forms![frmReports]![txtEndDate]
Behind the button click event, place the following code...
DoCmd.OpenReport "ReportName"
To run the report...
Open the form "frmReports".
Enter the beginning and ending dates into the text boxes.
Click the button you created.

SSRS - How to Get Filter Data to appear in Reports

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.

SQL Server Reporting Services - Set default value for multi-value report parameter

I have a report in SSRS and one of the parameters I use is Cities. The user can select from a list of cities to pull the report for that location, or multiple locations. My datset is simply a select * from tblCities. When I run the report, I do see that one of the options is "Select All." But, I'm wondering - is there a way I can get this "Select All" option as the default value, so that by default all cities are selected?
And, along those lines, but a separate question - is it possible to make this drop-down optional? I have tried the allow NULLS checkbox, but for multi-value parameters, it seems SSRS does not allow this.
FYI - I have only begun using SSRS; know very little about it.
is there a way I can get this "Select All" option as the default value, so that by default all cities are selected?
Yes you can.
Open the Report Parameters dialog: Layout tab, right click anywhere on the canvas that is not the report, select Report Parameters
Select the parameter (cities in this case), from the list on the left
Select the appropriate default setting in the default section, lower righthand corner
One option is where you can statically define a value. IE: =0 or whatever the value is for the Select All option. FYI: I've found that what works in the Visual Studio preview doesn't work when live.
Another option is if the list of cities comes from a stored proc, you order the output of the sproc so Select All is at the top of the list. Then you select the radio button under the static value one (can't remember, not at work to check ATM) - you'll have to select the dataset the sproc is associated with, then the column that the value comes from.
is it possible to make this drop-down optional?
When you say "multi-value", are you actually able to select multiple values from the list? IME, all you get is a drop down & can only select one of the options available.
Allowing null is just an accepted value - the optionality is really handled in the query so that if a sentinel value is provided then the criteria isn't included in the query. IE:
AND (#cities IS NULL OR t.city = #cities)
That's quick & literally dirty. ORs are poor performance.
Make these changes to the specified report parameter:
In order to have all fields selected, make the [dataset] and [valuefield] at "Available values:" equal to the [dataset] and [valuefield] at "Default Values" (assuming you have a query for determing this)
In reports when we want to default the multivalue parameter to 'Select All' following are the steps.
Open the Report parameter window from the Report menu.
Select the Report parameter from the left handside of the window.
Select 'Multi-value' checkbox and appropriate 'Available values'.
Under default values select 'From Query' radio button'.
Select the appropriate 'Dataset'.
Select appropriate 'Value Field'.
Save the Report and select Preview Tab. You will find all the items selected in the multivalue parameter list and the result displayed for all the selected items.
Go to the either the Data tab or the
Layout tab.
From the Report menu, select Report
Parameters
Select the desired parameters, in
this example, cities
In the lower right hand region of the
screen, set the Default values radio
button.
Set the Dataset and Value field drop
down lists to the exact same options
as the DataSet and Value field sections from the Available Values settings above.
This assumes that you are using the "From Query" option under "Available values" If you are using the "Non-queried", see the answer by OMG Ponies.