SSRS pulling the parameter from multiple location - reporting-services

I need to know if there is a way for us to display a single parameter report by pulling the same parameter from multiple drop down controls.
Does SSRS allow us to have multiple controls(drop down ) to pull the same parameter from different set of data.

If you have a server that can access the locations of the first two sets of data, then the easiest way to be for those would be to combine them into one with a UNION and use a single parameter for them.
I'm guessing that may not be possible so you can create a separate dataset and parameter for it.
Then create another parameter for your entered value. Allow these parameters to have a NULL value so that they do not have to be selected.
Create WHERE clause logic in your SQL to deal with the parameters for the LOT_NUMBER:
WHERE LOT_NUMBER IN (#INCOMPLETE)
OR LOT_NUMBER IN (#COMPLETE)
OR LOT_NUMBER IN (#ENTERED)
This will allow uses to choose from the first or second drop downs or enter a third value. The downside is that the user can potentially use all three at the same time.

Related

Generate 1 report based on multiple executions of stored procedure (passing different parameters to same procedure)

I have a SSRS report that takes a parameter and executes a stored procedure to generate a report with it.
the parameter is a values from a table that I have user select from a dropdown
let's say 15 options that are passed as parameters to each execution.
AAAA
AAAB
AAAC
...etc
is there any way I can setup the report so it will execute with each parameter and generate a report?
the issue is that now the user has to manually select 1st parameter, generate the report and then export the file result to excel.
what I want to do is a way for the user to select multiple parameters and export just one file containing all of them (the stored procedure can't take more parameters because of the way is coded depends on receiving one parameter only)
so it would have to schedule multiple executions of the stored procedure to create the report and then export this. is this possible? (as a note, the amount of parameters will change frequently so I need to give the option of selecting multiples from a list that is populated from a query to database)
and to clarify, the Stored Procedure needs to take only one parameter, this is not to be solved by sending multiple parameters to operate by using a splitter or similar, as the parameter received by the SP is used in calculations depending of order, (to not go into detail with the SP, just need to take one parameter per execution)
As you already have a report that handles a single option then you can do this easily using sub reports. Don't worry about the length of this answer it actually quite simple.
I would make a copy of the existing report to be safe....
Change the existing report to only accept a single parameter value if if doesn't already. Save this report, this will be your sub-report so let's say it's called mySubReport
Next create a new blank report.
Add a dataset (called say dsParameterList) that will give you the list of options you want the user to choose from (I guess this will be the same as your current report?). For example if it was a list of companies it might look something like SELECT CompanyID, CompanyName FROM myCompanyTable
Next add a parameter called say #options, make sure it is set to be multi-value and set the available values to use a query and point this to dsParameterList. Set the value and label fields as required.
Now create another dataset called dsLoop for example. This dataset will contain a list of selected parameter values. Using the company example from earlier the dataset query might look something like this. SELECT CompanyID, CompanyName FROM myCompanyTable WHERE CompanyID IN (#options)
Next add a table to your report and remove columns so that only 1 remains. Set the dataset property of the table/tablix to dsLoop. This means we will generate 1 row for every selected parameter value.
In the detail row right click in remaining textbox and choose 'Insert Subreport'. Now right-click the subreport placeholder and set the properties to point to the report we saved earlier (mySubReport in this example).
Whilst still in the sub report properties, click the parameters tab and add a new entry, choose the parameter in the left column and set the value in the right column to be the value from dsLoop that you want to pass to the subreport. In our company example this would probably be [CompanyID]
That's it. You run the report and choose from the parameter list, when you click View Report the dsLoop query runs and gives us a list of just those selected Companies, the report body is generated with a row for every row in the dsLoop dataset which in turn runs the subreport with a different parameter passed in each time.
Optionally You can right-click the rowgroup under the main design window and set the 'pagename' property to a value. In the Company example this might be =Fields!CompanyName.Value. When the report is exported to Excel each sheet in the workbook will be named with the name of Company

Display selected values of multi-value parameter in tablix rows

I am designing a report for SSRS. I want the user requesting the report to be able to specify, when they generate the report, from a pre-defined selection some values which should be displayed in a tablix on the report.
I have therefore created a multi-value parameter and populated the Available Values with the options I want the user to be able to select from, and, as expected, when the report is generated the user is able to select one or more of these values.
However, what I now want to do is include a tablix in the report, and display a row for every value in the multi-value parameter that the user selected, with the value displayed in the first cell of the row.
If the values were coming from a data table this would obviously be easy. I've also found answers on how to show all of the selected parameter values in a single textbox using the JOIN function, but I don't want to do that.
The only solution I can think of is to replicate the list of available values in the multi-value parameter in a tablix manually, and link the visibility of each row of the tablix to the selected state of the corresponding value in the multi-value parameter, but that's not very elegant and increases the effort involved in maintaining the report definition.
Any ideas on how to do this? I know the selected values from the parameter simply form an array, but I can't see how to bind a tablix to any data that isn't in a dataset, or how to create a dataset from the parameter values.
Considering that a tablix sources from a dataset, I did some experiments to see how to create a low maintenance solution for you.
Option 1: Create a data set with hard-coded options to match your multi-value parameter and select those options WHERE they exist in the parameter.
Example:
SELECT val
FROM (
SELECT 'opt1' as val
UNION SELECT 'opt2'
UNION SELECT 'opt3'
UNION SELECT 'opt4') a
WHERE val IN (#Param)
Thoughts: easier to maintain than visibility on a table, but still two hard-coded places within the report.
Option 2: Create a dataset that selects the multi-value parameter and splits it by each value. This was my first idea, but I ran into some issues with determining how to actually select the multi-value without a syntax error. I came up with a method that creates a deliminated string in the report and than parsed that string back into rows in the dataset:
Step 1) Within the dataset properties, on the parameter tab, join the multiple values together with a JOIN expression
Step 2) Create a simple query which uses the new SQL Server 2016 function string_split. Note that your database compatibility level MUST be 130 or higher to use this function (SQL 2016+). If this isn't your scenario, there are many string split functions that you can find on Stack Overflow to achieve the same thing.
Fun problem!

SSRS Pass parameter / Field value from 1 table to another

I am using SSRS 2012.
I have two datasets. I have two tables.
The first table contains a contract Id which is used as parameter in the second dataset.
I want to set the parameter as the contractId (ie Fields!ContractId.Value, or ReportItems!Contract1.Value) or something like that but nothing works because of different limitations.
If I would be using a subreport that would have been easy just pass the Field!Contract.Value from the 1st dataset as the parameter for the second and there you go. But since we want to call the report using SQL server agent, I cannot use subreport since the agent is limited and does not accept subreport.
So I believe my only option is to use two different tables, but I still need the value from the first dataset. Also, I don't think LookUp() would work for me as I do not have Ids.
Does anyone already did something like that?
Thanks for any help.
You can create report parameters in which the available values are pulled from a query.
Then just use the parameter in your second data set.

Access - Modular reusable subreport

I would like to create a report which I can use as a sub-report multiple times on the same parent report. However, each occurrence of the subreport should have different values.
For instance, there is a table called DailyReport.
Records in this table contain:
Date, member, team, description
The sub reports should be for each team within a certain date range. However, the date range per subreport/team will not be the same.
So, if the date range for all teams was consistent, then I could create a single subreport, and do some Ordering on the resulting records to separate things out into teams.
However, with inconsistent date ranges, I can't utilize a single query, so the most straight forward solution I see is to create separate subreports and queries for each range of each team.
The problem with this solution is that if I decide to change the format of the subreports I must do so in each specific subreport--a lot of duplicate work.
I would like to create a generic query and subreport. The query and sub report would call VB functions which would return the relevant value.
This means my parent report has the same generic report on it multiple times. As each subreport is rendered, I would like to increment a value behind the scenes so that the functions which the generic query and subreport call know to return a different value.
However, it seems that's not how things work in Access. The subreports on a report are not rendered linearly. A subreport is created, and then "stamped" onto a report where ever required. This means that all of my generic subreports have the same data.
How can I define a generic report and query? Then plug in different values into the report and query while the report is being reused multiple times on the same parent report.
You need to look into the LinkMasterFields and LinkChildFields property of reports. They are designed for exactly this purpose -- to filter a subreport based on current data in the main report, without needing any code or even queries.
You are correct that LMF/LCF do not work on date ranges, only values. So use LMF/LCF for the team filter.
For the date range filtering, you can use an unbound form that launches the report as two parameters defined in the base query. Create frmLaunch, and add two text boxes minDate and maxDate. Set their Format property to Short Date so Access with interpret them correctly and provide the date pickers. Now modify the base query, adding two Date/Time parameters [Forms]![frmLaunch]![minDate] and [Forms]![frmLaunch]![maxDate]. Now, find your date field and set its criterion to Between [Forms]![frmLaunch]![minDate] and [Forms]![frmLaunch]![maxDate]. Add a button to frmLaunch that runs the code DoCmd.OpenReport "YourReportName", acViewPreview.
So, the goal was to make it possible to re-use the same sub-report multiple times on the same parent report, with full flexibility on how the subreport retrieves data.
I placed multiple instances of the same subreport on a parent report. On the subreports Open event I placed a line like
Me.Report.RecordSource = "SELECT * FROM someTable WHERE " & getCriteria()
nextCriteria()
Maybe its possible to pass a value that identifies which instance of the subreport is opening to the getCriteria function. Probably like a getCriteria(Me.Report.Name). But in this case I kept track of how many subreports had been produced in vb.
Unfortunately, if your subreport has controls which have a data source which is a vb function, all reports will show the same value for that control. To get around this I added something like getSomeValue() & "As [Some Value]" into the SELECT of the SQL statement above. Don't forget to add single quotes or hashes around getSomeValue() if you are passing a String or date.
That's basically it, it's a pain. But I couldn't find a more elegant way to do it.
Edit:
One major caveat I experience with doing this, is that although the print preview works correctly, when actually printing or exporting to PDF, some subreports would not be included. Maybe there is something else causing this...

How to pass parameters to report model in Reporting Services

I'm developing report in RS that show top N customers based on some criteria. It also allows to select number of customers and period of time.
Is it possible to do it by using report model? Thing that it seems to be difficult is how to pass parameters determined by user.
Another thing that in my oppinion is very disappointing is that i cannot use SQL query as dataset query, because it uses odd and elaborate XML. Although report model items seem to map its fields to query or table fields.
I m concerning using report models because i need to provide uniform data model (the same tables and fields) for more or less different database schemas.
It would be very nice if somebody would explain what can be done with report models and what can not.
Maybe what you're looking for is to use the result of a Stored Procedure as the data source for your report. You would need to define parameters at a Dataset level to pass to the SP
You can create report model based paramaterized filters through the query designer by adding a filter, drag the field you want to filter on into the filter area, then right click on it and select "Prompt". This will automatically create a report parameter which you can then edit via the parameter properties dialog to set the data type, allow multiple values, etc.