Optional multi-valued parameters in SSRS - sql-server-2008-r2

I have 3 multivalued parameters in my report.Out of them 2 are optional.
Is there any way to get the results in the report with out selecting any from the 2 optional parameters.
My stored proc checks the mulivalued parameters as (States IN (SELECT * FROM Split(#State,',')))
I have done this for a single valued parameter with WHERE CustomerId = #CustId OR #CustId IS NULL.
WorkAround:
I selected 'Allow null value', it is throwing this error
"A multi-value parameter cannot include null values"
Can anyone point me in the right direction?

Have a look at this article on Passing Multivalued parameters.
Basically the above link contains a workaround to meet your requirement for an optional multivalued parameter. The steps to achieve this are as follows:
Replace "ALL" with " " (BLANK) in the parameter's dataset query.
Assign -1 as default parameter value for your multivalued parameter.

Related

How to add null value in Azure Datafactory Derived columns expression builder

I am currently using Azure Datafactory in that I am creating a Derived column and since the field will always will be blank, so I want the value to be NULL
currently Derived Column I am doing this for adding the expression e.g. toString("null") and toString(null()) but this is appearing as string. I only want null to appear without quotes in Json document
I have reproduced the above and got below results.
I tried to give null() to a column and it gave the error like below.
So, in ADF Dataflow, there should be any wrap over null() with the functions like toInteger() or toString()
When I give toString(null()) when id is 4 in derived column of dataflow and the sink is a JSON, it gave me the below output.
You can see the row with id==4 skipped the null valued key in JSON. If you give toString(null()) same key in every row will be skipped.
You can go through this link by #ShaikMaheer-MSFT to understand more about this.
AFAIK, The workaround for this can be to store the null as 'null' string to get that key in JSON like this and later use this as per your requirement.

SSRS multi value parameter - can't get it to work

First off this is my first attempt at a multi select. I've done a lot of searching but I can't find the answer that works for me.
I have a postgresql query which has bg.revision_key in (_revision_key) which holds the parameter. A side note, we've named all our parameters in the queries with the underscore and they all work, they are single select in SSRS.
In my SSRS report I have a parameter called Revision Key Segment which is the multi select parameter. I've ticked Allow multi value and in Available Values I have value field pointing to revision_key in the dataset.
In my dataset parameter options I have Parameter Value [#revision_key]
In my shared dataset I also have my parameter set to Allow multi value.
For some reason I can't seem to get the multi select to work so I must be missing something somewhere but I've ran out of ideas.
Unlike with SQL Server, when you connect to a database using an ODBC connection, the parameter support is different. You cannot use named parameters and instead have to use the ? syntax.
In order to accommodate multiple values you can concatenate them into a single string and use a like statement to search them. However, this is inefficient. Another approach is to use a function to split the values into an in-line table.
In PostgreSQL you can use an expression like this:
inner join (select CAST(regexp_split_to_table(?, ',') AS int) as filter) as my on my.filter = key_column
Then in the dataset properties, under the parameters tab, use an expression like this to concatenate the values:
=Join(Parameters!Keys.Value, ",")
In other words, the report is concatenating the values into a comma-separated list. The database is splitting them into a table of integers then inner joining on the values.

The default expression for the query parameter contains an error

I have a dataset referencing a proc. That proc takes in a #UserName
In my parameters of my dataset, I have specified a new param called #UserName and for its default value the expression =User!UserID but I still get this error when the report tires to render:
The default value expression for the query parameter #UserName contains an error [BC30654] 'Return' statement in a function, Get, or Operator must return a value
The only thing I can think of is that instead of modifying the existing datasource I had defined in the report, I removed and added a new datasource. I hope that doesn't matter as long as there is a valid data source for the report to go on that has those fields...I just switched this report to reference a copy of our current database for testing purposes.
Sounds like the report parameter is not being passed to the stored procedure.
In the Dataset Properties, click on the Parameters tab and check that the stored proc parameter #Username is correctly mapped to the Report parameter #Username.

Accessing Parameters from the Main Data Source from A Secondary Dataset

I've got a chart that uses a secondary dataset. It allows for the use of the fields and parameters of the second dataset, however I'm not able to use the parameters set in the main report dataset. Does anyone have any clue how to access the values of the parameters?
For example
I have the following parameters in the main dataset:
valueOne
valueTwo
And a secondary data set:
fieldOne, fieldTwo
From the chart that is set to use the second dataset, how would I request parameter: "valueOne"?
Add a parameter to your subDataset that has the exact same name as the parameter in the main dataset. Leave the default value expression blank and do not prompt for a value. When you reference the parameter in the subdataset, the value from the main dataset will be returned.
So in your case monksy, you should add an empty parameter named "valueOne" to your second dataset.
I've never seen this behaviour documented anywhere; I found it out by accident when working on a report.

how to pass null value when the parameters are left in empty

I am developing a Crystal Report from the database, and am setting a parameter's value in Crystal Reports itself, with a Command object. My issue is that when I run the Crystal Report, if I leave any parameter as null, it will return all the records from the database. How is that possible?
If you're using parameters in a Database Command, you can't use optional parameters. However, if you're using CR2008 (I think that's when they were added), you can set your parameters as optional, and then use the HasValue() function to see if the user selected a value.
RecordSelection:
If HasValue({?MyParm}) Then
{Command.MYFIELD} = {?MyParm}
Else
True;
Crystal Reports requires each Parameter Field to have a value; nulls aren't allowed.
If you are using a Command object, you will need to use syntax like this in SQL:
--t-sql syntax; assumes numeric value and -1 is the value chosen to represent 'all values'
WHERE table.field = CASE
WHEN {?command_object_prompt} = -1 THEN table.field
ELSE {?command_object_prompt}
END
If you are using 'standard' database linking (as opposed to a Command object), look at my posting Crystal Reports: Optional-Multi-Select Parameters.