SSRS dropdown with progressive search - reporting-services

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.

Related

Report Builder - Use one dataset in the where clause of the query for another dataset

I'm using SQL Server Report Builder 2014.
DatasetA is created from TableA in DatasourceA and contains a single column of IDs.
DatasetB, on which my report is based, needs to have all rows from TableB in DatasourceB WHERE TableB.ID IN (DatasetA).
I've done lots of Google'ing, but cannot find a solution that works. Suggestions?
For this you could use a hidden parameter in the report, lets call is ParamA. Populate ParamA using DatasetA, set it as a multi-select parameter and set the defaults using DatasetA i.e. all items will be selected.
Then in DatasetB have where id in (#ParamA)
As I know, when you use where name in (#aa) in query designer(text mode) and click OK, it will prompt like below
You could hard code in it, it seems to support single parameter to test in designer, but when you preview it in report, you could pass multiple parameters. You could click OK to ignore it or pass hard code in it to see whether parameters could work or not.
In addition, if you want to show dataset A's value in parameter list, you could set available value in parameter properties (get values from query)

Searching a database in Report Builder 3.0

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.

SSRS: is there a way to display a multivalued parameter in a table?

Using SSRS 2012
I have a multivalue parameter in a report and I would like to make it the source of a table. Is there a way to accomplish this? I'm coming to the conclusion that one cannot make the data source of a table anything except a dataset.
I tried to make the multivalued dataset (source of parameter) filtered by parameter but that gives a forward reference error (makes sense).
I am now trying to set the visibility property on the table's single text box like this, so it will only make the values visible that are one of the chosen parameter values:
=IIF(Fields!MODALITY.Value = Join(Parameters!Modalities.Value,","),True,False)
but they are all shown (alway true?). Any ideas on how to show a list of the values picked from a multi valued parameter in the report as a table (not just a delimited string in a text box)?
The data source of a table will always be a dataset, but you can use the parameters in a dataset. Something like
select * from dbo.split3(#parameter)
where split3 is a csv to table function, like one found on http://blogs.msdn.com/b/amitjet/archive/2009/12/11/sql-server-comma-separated-string-to-table.aspx
I found an expression that works for changing visibility so that my table shows just the elements in the multivalue parameter that were selected. Perhaps there's an easier way.
=IIF(Instr(","+Join(Parameters!Modalities.Value,",")+",",","+Fields!MODALITY.Value+",") <> 0,False,True)

How to reference in SSRS report (in client mode) objects from application

I have a report created in SSRS in client mode, which is run disconnected: I create the data source in code and pass to the report as a DataView. It works ok.
But I need to be able to reference from the project to some objects (variables, whatever) from my application, as follows:
I need some totals that are not calculated based on data in report. e.g. the reports show total sales in a period, with own total, but I need to display a field in report footer - previous month total (actually they are about 10 other "previous" totals).
I need to have some columns show / hide based on some settings in the application (e.g. I have application option : Show Previous month sales)
Any thoughts on how to do this?
Thank you
Q1-> In order to use data in your reports, you need to specify the data inside of a Datasource object. You cannot simply use the variables if that is what your intentions were. So yes, you are doing this the right way. *** Sorry, you could theoretically used Report Parameters for this.
Q2-> This is the real reason to use Report Parameters. You can pass parameters to the report to do exactly this. If the HideColumn parameter (for example) is set to true, you could hide all the columns that need to be hidden.
http://msdn.microsoft.com/en-us/library/ms251750%28VS.80%29.aspx
For question 1 - the data - the easiest approach would be to create a DataTable in memory and add it as another dataset OR to add fields for your original dataview that contain these values.
Question 2 - To hide or show the columns based on settings make the column visibility an expression based on the value of a parameter, in your code behind set the parameter value to your application setting.

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.