SSRS 2012 issue around multi valued parameters - sql-server

I have a parameter question in SSRS . I currently have 3 parameters set up, Permanent Employee then select P, Temporary Employee then select T and Partner Employee then select P.
So the user selects parameter one , Permanent and then selects parameter two, Temporary and then the third parameter, Partner.
This then feeds into my sql query to return the result set....like below .
AND (A.[EMPTYPE]=#EmploymentP1
OR A.[EMPTYPE]=#EmploymentP2
OR A.[EMPTYPE]=#EmploymentP3 )
So the question if I wanted one parameter that will allow one or more of the values to be selected, Permanent , temporary or Partner
to be selected. How to do this ? So a multi value parameter in SSRS. But how do you then feed those results into the query is the bit I dont understood yet. Any ideas?

If for example your single parameter was #Employment, you would use:
WHERE A.[EMPTYPE] IN (#Employment)
SSRS Internally parses this to valid syntax before sending the query to the database.

Related

Passing multiple string parameters to a another report via "Go to report" Action

I had similar question for sub report and was answered:
SSRS passing multiple string parameter to another report
However this time I would like to pass my parameters to a different report instead of a sub report.
For the first report, my ponum parameter consist of string like 'a-01', 'b-02', 'c-44'...
and then perform a query that like
select column_X from table_1 where ponum in (#ponum)
and then user click on a expression link which send the rows to another report to perform another action via a query. such as
update table_1 set column_A = '123' where ponum in (#ponum)
My problem is I can't send the parameter as a multiple values parameter. I added an expression for user to click and added the parameter in this window
I also tried
=join(Parameters!ponum.Value,", ")
="'"+join(Parameters!ponum.Value,"', '")+"'"
In Report_2, I set up the parameter as this
Unfortunately, the report it goes to only receive the first value or the query doesn't work and parameter being the problem.
Would like to hear any idea that might work.
Thanks in advance.

How to add 2 data sets in SSRS

I have 2 data sets that have the common column VNO. Now I want to get the report in ssrs like
VDate, Count('') from B for Vdate, Count('') from A for Vdate
Can anyone help me with the way, I tried the lookup but not able to get this output.
Note: I cannot join these two tables in SQL as these 2 tables are on separate instances and they are not connected and don't have permission to do so.
You need to use LOOKUPSET() . This returns an array which you can then check the length of like this
=LookupSet(Fields!InvoiceDate.Value, Fields!VDate.Value, Fields!VNO.Value, "DataSetB").Length
The 3rd argument is the returned value but as you are only getting a count, it does not matter what we return there. DataSetB is the case sensitive name of your second dataset.

Constraining columns with each other in SSRS

I'm learning MSBI tools and came across a requirement in SSRS wherein we need to constrain report parameter 2 with parameter 1.
i.e. if I have parameters setup on [AdventureWorks2008R2].[HumanResources].[Department] table and if I select "Group Name" (Parameter 1) as "Manufacturing" then the "Name" (Parameter 2) drop down should populate only relevant values("Production" and "Production Control") specific to selected parameter 1 value ("Manufacturing")
I have been exposed to OBIEE tool and know that under this tool we have a "constrain" option under Prompts to achieve the same.
I could come up with the following solution under SSRS:
Created two datasets for each of the parameters with below queries.
Parameter 1 (GroupName)
SELECT DISTINCT GroupName
FROM HumanResources.Department
Parameter 2 (DeptName)
SELECT Name
FROM HumanResources.Department
WHERE (GroupName = #GroupName)
This worked. However if there are 5 such parameters which are to be constrained then with this solution I would have to create 5 such datasets and accordingly build the WHERE clause for each parameter.
Is there a better solution to achieve the same (there should be..)
I'm new to SSRS and therefore would appreciate any pointers here.
Thanks!
What you are talking about is called "Cascading Parameters" and they are implemented exactly as you did. You can read about them here:
Adding Cascading Parameters (SSRS)
So if you need to implement 5 of such parameters you have to write 5 queries for 5 datasets each one containing WHERE referencing parameter defined in previous dataset

Printing records with condition Crystal reports

I am using stored procedure in mssql as backend, vb.net as frontend (just info).
There are a lot of records in the database and I am printing in crystal reports.
Now I want to filter the records from crystal report and not by adding a new parameter to procedure or changing database structure or else.
For now,Say there are columns : Name , Amount.
I want to put filter in amount like only display records whose amount above 100 or something. So other records with less than 100 should not be displayed.
This filter will be passed by the user so it'll be random.
I can't find a proper answer on internet. Might be a duplicate question, if so please post the link of the question if it is duplicated.!
Thanx anyways...!
In general the idea is to:
Create the parameter (user choose what will be the input/value) - link
Set filters, what values should be displayed in regards to parameter - link
On right side there is a DataExplorer window, where You need to add a Parameter (define his name, what question will be shown to user and what type the param will be / what values can be set inside).
Once done, You can jump to Data tab of a report, click Interactive Filter and specify which column must fit what condition with what value = Parameter (that one user will enter in Report).
Example: I will create AmountParam, with message "What should be the minimum amount?". Type will be set to Integer. Going to Report->Data->Interactive Filter, choose Amount as a Column, AmountParam as a Parameter and set condition Greater then (>).

how to pass this information to SQL Server 2008?

Please visit http://www.stumbleupon.com/
It asks you what interests you.
I would have a similar thing on my website except I would need to have 4 of such non-identical blocks. When a user has not selected anything in a section, it means s/he has selected all of them. 1 of these blocks would have around 10 options while the other 3 would have 2-3 options each.
How do I pass what all a user has selected to SQL Server 2008? Please note I would have 4 sets of multiple params, and these 4 sets are basically 4 different columns in the row all containing integer id's. If and only if one param per section was passed, I would have done something like
select * from table where column1 = #param1, column2 = #param2 and so on.
but that is not the case, because a user could pass multiple values for #param1 and so on.
I can get this done, but I want to know the most efficient way.
If my post is not clear, please let me know.
EDIT:
Basically, if I am storing articles in the database, I have 4 columns in the row, each integer. And I want to query these articles based on these 4 columns, but the catch is to pass the multiple values for these columns NOT just one value per column.
If your client language supports it, you should look into table value parameters:
http://www.sqlteam.com/article/sql-server-2008-table-valued-parameters
if you can't use those, look into one on Arrays and Lists in TSQL:
http://www.sommarskog.se/arrays-in-sql.html
this is a very comprehensive list of dynamic search conditions in TSQL:
http://www.sommarskog.se/dyn-search.html
this may also help:
Sane/fast method to pass variable parameter lists to SqlServer2008 stored procedure
Try dumping all parameter values into the XML, then pass it to SQL Server, then parse it in the query.
Won't such a query work in this case?
SELECT *
FROM TABLE
WHERE COLUMN1 IN ( #param11, #param12, #param13 )
AND COLUMN2 IN ( #param21, #param22, #param23 )
and so on.

Resources