ssrs:add null value to multi value parameter didn't work - reporting-services

in order to allow a selection of null value in multi value parameter in SSRS project
we can use the query for the data set
Select ID,Value From SpecificTable
Union All
Select NULL,'Other'
in order to let null value returned from parameter when 'other' string is selected from parameter available selections
note:in available values section at parameters properties i have chosen ID Column as Value Field and Value as Label Filed
i have tried the previous query with no be benefit ,the string 'other' doesn't appear as available selection for the parameter when i preview the report
are there any additional configurations that i should apply ?

I don't think you can do it this way... that's why "Allow Nulls" is an option.. what you can do is set the ID value for Other to some obscure value.. like -99.. which the actual ID from the specifiectable can never be.. and modify your stored procedure to say..
where (#id = sometable.someidcolumn or #id = -99)
This should in effect ignore the ID selection! Unless you want it to do something else of course.. then you code accordingly in the where clause.

Related

SSRS Optional parameter with empty field

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.

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))

If Parameter A = (Select All) then Default Parameter B to "Y"

I have a report i have been asked to write from a procedure i did not create the procedure has 2 parameters for each of the options.
#AreaID
#AreaID_All
So They coded this way if you wanted to search for a specific Area id you would input the Area ID into #AreaID and then input "N" Into #AreaID_All.
If you wanted to show all then you would input NULL into #AreaID and "Y" into #AreaID_All.
It was also requested that there be a multiselect dropdown for the #AreaID.
I have this part down, now im stuck on how to say if the User Selected (Select All) in #AreaID then Default the #AreaID_all to "Y".
Any Ideas?
You can create another dataset that returns the count of AreaID rows you are passing as available values to the parameter.
Then use it to compare against the Parameters!AreaID.Count function.
#AreaID_All set expression would be something like this:
=Switch(
...
...
First(Fields!CountofAreaID.Value,"CountDataSet")=Parameters!AreaID.Count,"Y"
)
This means Select All option was select.
Also I strongly suggest you have an internal parameter to validate the data your #AreaID_All is getting from the user.
Let me know if this helps.

SSRS Check if Parameter exists

I have a report where the user must enter an order number, this then populates tables and charts etc.
What I need to know is how do I go about informing the user that they have entered an invalid order number?
so a sort of 'IF #ORDERNO IN (SELECT DISTINCT ORDERNO FROM ORDERS) then the data will be displayed else a textbox will show at the top of the report saying Invalid Order No.
I could provide them with a list of OrderNumbers to select from as the parameter but there's too many to make this feasible.
I know you can add a Textbox with an expression with an IIF and check a value, but is it possible to check that value exists in a dataset?
Is norowmessage property of the table works for you?
Select your table->press F4-> Put relevant message under
NoRowsMessgae property
Create another parameter and have it populate the order # if it exists.
Parameter1: Enter Order: 54455
DataSet2: Select 'Valid Order' As "Confirmation" from Order_Table where Order_number = :Parameter1
Set Default Value of Parameter2 to display Confirmation value as Default
This way, they'll know if they have the right order even before they run the report.

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.