SSRS Optional parameter with empty field - reporting-services

I need to run the report, without selecting anything, with parameter field blank, and be able to view all the data.
the problem is that it necessarily asks me to enter a value (all or multi values).
Who can help me?

If you make sure that you do the following...
Set the parameter to "Allow blank value" and/or "Allow null value" depending on what datatype it is.
Set the default value to Blank (="") if applicable
If you have a list of available values set, make sure the default value is included.
The following example uses sample data from sample database and contains just a list of company names and their ID's.
The main dataset query filters the data based on 2 parameters (one is text the other id numeric to show different scenarios)
This is the dataset query
SELECT CustomerID, CompanyName
FROM [AdventureWorksLT2019].[SalesLT].[Customer2]
WHERE CompanyName LIKE '%' + #pSearch + '%'
and CustomerID > ISNULL(#pID, 0)
ORDER by CompanyName
The report design looks like this with 2 parameters defined
The first parameter is text and has "Allow blanks values" checked, the Default value is set to an expression =""
The second parameter is an integer, This time we have set "Allow null value" on but we have not set a default value.
Note: Neither parameter has any available values set...
When the report is run I get the following results without pressing anything.
Only if I manually set any of the parameters do I need to press View Report, but when the report first runs, there is no need to click anything.
If the above does not help, then show how the parameter(s) are setup up, what types they are, what the available values are and what the default values are.

Related

Report Server: how to select everything if parameter = null or blank (allow multiple values is turned on)

How to return everything in Report Server if parameter value is blank or null?
The solution:
SELECT some_column
FROM your_table
WHERE (#y is null or y >= #y)
Doesn't work in SSRS since "Allow null value" cannot be turned on, when parameter "Allow multiple values" is turned on.
Thank you.
There are a couple of ways around this but the simplest is just to use the "Select All" option at appears at the top of multi-value parameter lists. If you need this to be the default then set the default and available value to the same query.
The "Select All" option is shown automatically for multi-value parameters when there is more than a single value in the list as shown here..
Other ways are similar, for instance you can add a value to the top of your parameter's available values list that has a label called "All" or something like that and a value you can look for in your query (e.g. -1).
BTW: Your sample code would not work with a multivalue parameter if used directly in the dataset query you would normally do something like
SELECT some_column
FROM your_table
WHERE (#y =-1 OR y IN(#y))

how to create a textbox in ssrs for user entry as a parameter

I have a report that has three params. one is dropdown. It created automatically when i supplied
name and value, Then If we select multivalue, it shows multivalue dropdownlist.
But I am not able to create a textbox. That will act as a parameter to be supplied in report.
for that I have created a parameter, set it to allow null and datatype = "text" .
parameter visibility is also visible but as a result I can see a textbox which is a disbled one.
How can this textbox be made to work?
While in the Report Parameter Properties for the text field in question, chose Allow blank value (rather than Allow null value). In the Default Values section of the properties dialog, choose Specify values, Add a blank default value.
Now you will have a working text field that the end user can type into, and you can use that value for searches in your query.
Hope this helps
To allow user to enter the parameter value manually:
Right click on the parameter and select Parameter Properties
On the Available Values tab, select None
Click OK
Now users can manually type in the parameter value.
Click to see screenshot

SSRS Multiple Parameters in a single dropdown

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

Report Manager - "Select all" as default for some linked reports

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.

Using optional multi-value textbox as dataset filter

I have a report which returns list of product names and other product specs. This report currently has different search options. My users now also want to be able to search by product number by putting in multiple product numbers.
How can I add a filter by product number which is an optional multi-value textbox?
I have tried to add a multi-value textbox. The report doesn't seem to work when no values are entered. If I put one or more product number in the text box, it seems to work fine. Is there a way I can tell the report doesn't filter on the Null value parameters? Or any other idea to work with optional multi-value parameters?
Here is the setting for my multi-value textbox
Name = ProductNumber
Prompt = Product Number
Data Type = Text
Allow Blank Value (checked)
Allow Null value (not checked)
Allow Multiple Values (checked)
Here is the data set filter
Expression = [ProductNumber]
Operator = In
Value = [#ProductNumber]
Thanks
TL
I think you should trick the dataset filter by:
Expression should check to see if the parameter is blank and if so give expression a 1 else the field.
Value should do the same check and if parameter is blank set value to 1 else set it to the parameter.
But keep your operator.
Alternatively you could do this similarly in the SQL and with more flexibility and performance.
So as you've seen in your own testing, at least one value must be selected with multi-value parameters. You can't set Allow null value to true at design time and if you run a report without selecting any values it will throw an error message.
So you can't really have a report where users can run it with no values selected.
Taking a step back, what you're trying to achieve when ignoring the parameter is to include all Product Numbers by default. So why don't you set the parameter to have a default value of all Product Numbers selected? That way, users can just ignore and leave them all ticked if they don't want to filter by Product Numbers. Seems like a good workaround to me.
To do this, set the default value for the parameter using the same dataset that populates it:
All Product Numbers are now selected and users only need to take action if they want a subset of these returned.