SSRS Report - Dynamic Parameters causing awful slowness - sql-server

I've built an SSRS Report with a series of parameters and data sets a user specifies a season (first parameter). There are several data sets -- see below.
The first is a procedure: called LRP_Weekly_Stats returns 9 fields (including, location, eventdata, option, season, and a few others.
The second data set pulls - all the distinct seasons from a view - that gets sent to the parameter drop down. select distinct season from myview it shows/returns just season.
2 additional data set exists it reads
select distinct location from myview where my season = parameter season
and
select distinct option from myview where my season = parameter season
each of these data sets return location and option respectively.
We can't build this as 1 single data set because each of the 5 locations has each of the 4 options associated with and the data being returned gets multiplied by itself.
Data in my view looks like this
Location option
-------------------------
Location1 option1
Location1 option2
Location1 option3
Location1 option4
Location1 option5
Location2 option1
Location2 option2
Location2 option3
Location2 option4
Location3 option1
Location3 option2
Location3 option4
Location3 option5
etc.
In order for the parameters to show each location once and each option 1 for the parameter drop down we do two separate queries.
I didn't build the view and can't adjust it and even if i could the data is such that each location can have each option.
so my two data sets each return the distinct list of possible locations and/or options by season.
in the parameters in the SSRS report the set up looks like this:
so the data coming in to my parameter is pulled from my data set. for each of the three parameters. location and option_1 and option_2. The code itself runs in under 5 seconds however because of all this linkage it takes a good 30+ minutes to run the report. This is completely unacceptable (and I can't remove the drop down data because the users need it).
Any advice about how to streamline this or make it more efficient. Please help.

Based on your reply in the comments on your initial question, it looks to me like the issue is either in the report procedure itself, or possibly a rendering issue. I would look at performance tuning the main report queries. And I'm afraid I can't be more specific than that without knowing a lot more details about your report's architecture.

Related

Is there any approach to get access the Sub report variable or to get SubReport element in main report?

I am writing an SSRS report in which I've a tablix that actually contain a subreport in one of its table cell. Now I want to understand to get this value as Sum on main report. For example, below is the student data:
Student Name | Total Subject | Obtained Marks (Sub Report)
XYZ | 6 | 35
ABC | 6 | 46
In above example, I am able to see the total marks of the first subject only. But I need to get the total form all 6 subjects from sub report. My tablix is already has Grouped by Student Name.
Below are the ways I tried to get it done:
Added another column in tablix and try to get the subreport as ReportItems! Subreport2, didn't work.
In the same column, I tried with Sum (Subreport2).
But since Subreport2 as report items are not accessible I'm not able to get it done.
UPDATE 1
I am using below expression to get sub-report value:
=ReportItems("Subreport2").value
The short answer is, no, you can't access fields from a subreport in the manner that you are attempting to. However, there is an easy way to get the values from that subreport that you may not have realized. The basic solution is to simply add another dataset to your report using the same query or stored procedure that is used in the subreport and getting the required data from that dataset. For example, you could then use a lookup function to match the data as needed. The lookup function requires four parameters detailed in the following expression.
= Lookup([SourceValue].Value, [DestinationValue].Value, [LookupValue].Value, "[DestinationDataset]")
The idea in your case would be to put your student name or ID field from the main report dataset in for source value, match that value in your subreport dataset for the destination value, get the value you need for lookup value, and the subreport dataset goes in parenthesis to indicate where to get the data from. So the following expression gives you an idea of what you need.
= Lookup(Fields!studentID.Value, Fields!studentIDSub.Value, Fields!ObtainedMarks.Value, "SubreportDataset")
Take a look at the documentation if you need any addition information.

SSRS Subreport Inside a Table Cell not Retrieving Parameters Properly?

I have an SSRS Report using a Table.
You can select multiple Clients and Periods and for every pair there will be a row in the table. So 2 Clients * 3 Periods = 6 rows.
Now... there are some cells that are more complicated than having a single value and I want to place a subreport inside these cells. The Subreport will take the Client and Period for that particular Row as params.
This is where the issue comes in. The Parameters will not pass properly.
I can put Parameters!ClientID.Value(0) as an expression for example and it will pass the first ClientID properly but if I just put Parameters!ClientID.Value it breaks... And I want the Client/Period for the current row.
But how is it that I can't pass the params but CAN fill a new dataset for every row based on that Client/Period pair??
Note that I'd really prefer not to have to edit the SP that builds that dataset to return the Client/Period itself. Sure that would work.. but WHY would that be needed when I have the Parameters?
Any ideas? I'm doing this in a Visual Studio Report Project.
If I've understood correctly you don't need to use the parameter. You need to use the value of the field from the dataset. So if your table shows client and period then the parameter values passed in would be =Fields!Client.Value and =Fields!Period.Value
Client Period SubReportCell
Bob 2017 "subreport here passing in Bob, 2017"
Geoff 2015 "sub report here passing in Geoff, 2015"
You should just be able to choose these from the dropdown lists in the subreport setting dialogue box.

Different drill through for each row

I have an SSRS report with several levels of drilling down. Data is aggregated up for the top level view, but I need to show a different drill down report depending on the type of one of the columns.
Eg:
Table 1 - Apples
Name Cost
Fuji 1.5
Gala 3.5
Table 2 - Squashes
Name Cost
Pumpkin 2
Gourd 4.5
I have a stored procedure which aggregates these and puts them in a table for the top level report to show. Ie:
Name Cost ItemType
Apples 5 1
Squashes 6.5 2
In reality, the two tables have different columns which I need to show in the drill through reports. Is it possible to look at the ItemType column and either drill down to one of two sub-reports, depending on it's value?
If you need to choose between two or more different sub-reports then make the ReportName property of the action on the textbox an expression like this.
=IIF(Fields!ItemType.Value = 1, "subReport_Apples", "subReport_Oranges")
if you have more than a handful SWITCH will probably be better
= SWITCH (
Fields!ItemType.Value = 1, "subReport_Apples",
Fields!ItemType.Value = 2, "subReport_Oranges",
Fields!ItemType.Value = 3, "subReport_Lemons",
True, "subReport_AnythingElse"
)
If you have a LOT of item types, consider adding the names of the subreports to your database creating a new table containing ItemType and subReportName. You can then join to this in your query and get the actual subreport name. The ReportName property of the text action would then simply be Fields!SubReportname.Value
You can add the ItemType as a parameter in your subreport(s). Then from your main report just link or jump to the sub report and pass along the Fields!ItemType.Value in the parameter configuration tab.

Change a label in a multiple value parameter in SSRS

I'm trying to change a label under certain circumstances for a multi-value parameter. A stored procedure is the source for the values in the dataset that is used for the parameter. For example the parameter gets:
ID | NAME
-----------------
1 | Name 1
2 | Name 2
3 | Name 3
I'm mapping ID to the value and NAME to the label. I want "Name 2" to display as "Name Two" in the drop down but all others to keep the value fed in from the query. I can use an expression in the report like
=IIF(Parameters!PARAM.Label = "Name 2", "Name Two", Parameters!PARAM.Label)
but is there any way to do this same thing to the parameter label so it gets modified before being displayed? I know I could massage this in the query so it comes into the report as I want but I am hoping I can handle this in report builder.
I am using Report Builder 3.0 with SQL Server 2008 R2
I believe that the SSRS report renderer does not allow the parameter values to be determined via formula in properties. It probably has something to do with the order of when the form renders versus pulling the dataset.
Sorry for the bad news. It looks like you will have to accomplish this via the actual query feeding the parameter set.

SSRS: 2008 run same procedure with diff params for multi month report

I'm all about recycling-)
I have report that user want to run for selected number of month back (let say from 1 to 12).
If they selected 6 month back (Jul-13 thru Jan-2104, then I need to produce 6 pages with monthly report on each of them, and sp is the SAME for all reports just different time params.
How I can reuse my code??
For now I have 12 Tablix(s) with New Page=START, Hide condition set based on datediff(m,startDate,endDate) individually for each Tablix.
Then I need to run same sp with diff params, can I add some dynamics into it? or I better to have 12 sp(s)?
Thanks
Mario
You can achieve this with a single dataset and a List Report Item with an embedded Tablix:
Set the List Grouping to Group/Sort first by: =Year(Fields!YourDateField.Value) and then by =Month(Fields!YourDateField.Value).
Set the Page Breaks on the List Grouping to "Between each instance of a group".
Drag your Tablix inside the List Report Item.
Let me know if you need more detail.

Resources