Where clause in RDLC reporting - asp.net

=iif(Fields!SubjectCode.Value=Parameters!SubjectCode.Value,Fields!SpAbsentCount.Value,0)
I have a Main Report and a sub report
SubjectCode parameter is passed to the subreport from the main report
for each subject code sub report is generated. based on the subject code I need to select a single value(SpAbsentCount) to display on the sub report
something like select... from... where SubectCode=#SubjectCode
I tried the above expression but it doesn't work

Hard to say exactly without knowing the data and setup of your report, but one guess I have is that you have a whole set of values, and your IIF expression winds up looking at only the first row of values. Try creating a tablix or list that filters on the SubjectCode, then using your code.

Related

Single prompt parameter(Date Range) for shared parameter in sub-reports' queries in Access 2010

I am using Access 2010 and have used a sub-report in the main report. The main report comes out fine, but the date range parameter (Between [enter start date] And [enter end date]) has been asked twice, one time for the main report and another time for the sub report.
I would like to parse the parameter only once. I followed below method mentioned in one of the article, but the numbers are wrong since the sub report takes only very first date from the result and parse it to the sub report(instead of parsing both "From" and "To" values.
Please help to enter the date range just one time.
I have followed:
You need to put your parameter in the query behind your main report and make it come out as a field:
SELECT YearParam:[Enter Year], <<Other Fields Here>> FROM <<Table NAME>>
Then on the main report, place a textbox in the Report Header with a control source of the field name (YearParam) and name the textbox (txtYearParam, for example).
Now, on each of the queries behind your sub-reports (or on the report filter) make it look at the main report textbox using the following syntax:
Reports!ReportName.txtYearParam
Article link.

SSRS Sub-Report only using default parameter to create dataset, even though parameter is successfully being passed from the main report

I have been working with SSRS for the last year and a half or so. Everything I know from it has been learned by trial and error and google. So hopefully I get my terminology correct, but forgive me if I say something incorrectly.
I am using Visual Studios 2015, connecting to SQL 2012 server. I'm creating an asp.net/VB web application to display SSRS reports on a local site. All of my reports up to this point have been a single report with no sub-report. If "sup-report data" was desired, I created a drill-through, using an Action, to navigate to a completely separate page. This has been working really well for all my reports, but now I would like to get a little fancier.
I have been trying to create a SSRS report that contains a sub-report. The main report contains summary information about batches of a particular product that has been run (blue and white portion of the table in the picture).
If a user wants to view more specific details about the batch, they can click on the expand/collapse button of the "Process Order" column, and a sub-report below the summary line will appear with more specific information about the batch (sub report is the light grey/dark grey table).
I configured the properties on the main report to pass the ProcessOrder value as a parameter on the sub-report and create a parameter on the sub report to accept this parameter.
You can tell that this parameter is being passed successfully because I have the respective parameter being passed and displayed just above the table (and it matches the number on the main table). As you can see from the picture, I also have the Process Order number displayed on the sub-report table itself, and this number is different than what is being passed to the report. It is showing a "1", which is the default value that I gave to the SQLDataSource control on my aspx page to build the dataset. I've tried not setting a "Default value" but then I get the following error:
“Data retrieval failed for the subreport, 'test_Sub_Report2', located at: [location on hard drive] Please check the log files for more information.”
Has anyone encountered this problem before, or can anyone give me an idea of a direction to go from here? I feel like I’m very close since I’m getting the parameter successfully passed to the sub-report, but the dataset is just not using that parameter to go get the data from SQL, and I’m not sure how to tell it to do so.
I can add more details and post more of the actual code, just let me know what you need and I will do my best to get it to you. I would have included more screenshots, but I don't have enough rep points to do so yet.
You need to go into the DataSet that populates the sub-report, and go to the Parameters tab, and map the ProcessOrder parameter of the dataset to the Variable that you pass the ProcessOrder parameter to from the main report.
I ended up figuring out the answer. I used the answer from #Lazy Coder on this question: SubReport is not working after adding parameter I was adding the parameters to the sub-report incorrectly. I did have them passed to the sub-report through the table on my main report, which was getting the parameters to the sub-report, but the sub-report was not using these values to create the data set. On my test_page.aspx.vb file I had to change my SubReportProcessing Event Handler. I needed to explicitly set the parameters values there. Since the time that I originally posted this question, I added another parameter to my stored procedure as well, subTotalTime, to correctly filter my results.
Public Sub SetSubDataSource(sender As Object, e As SubreportProcessingEventArgs)
Dim report = DirectCast(sender, LocalReport).DataSources(0)
Dim subProcessOrder = e.Parameters("subProcessOrder").Values(0)
Dim subTotalTime = e.Parameters("subTotalTime").Values(0)
SqlDataSource_PPMS_test_Sub_Page.SelectParameters(1).DefaultValue = subProcessOrder
SqlDataSource_PPMS_test_Sub_Page.SelectParameters(2).DefaultValue = subTotalTime
e.DataSources.Add(New ReportDataSource("DataSet2", SqlDataSource_PPMS_test_Sub_Page))
End Sub
SqlDataSource_PPMS_test_Sub_Page is the id of my SqlDataSource object on my aspx page.

how to clear subreport value in telerik report

I am using Telerik Report in ASP.NET. I have one master report and inside that 2 sub report.
The formate of my report is for each unit I want to print sub report.
All are working fine but problem is sub report displaying only last record only those are assigned last in loop.
I have 8 record in the database. while I debugging my code it assigning proper value to sub report. but on output it showing last two record for all unit.it means sub report displaying same data for all unit.
I am assigning sub report data from function, I am not using any event for assign report source to sub report.
can any one please give me solution about this...?
Thanks

SSRS how to display parameter in heading when no rows are returned

I am using Visual Studio 2008 to build a base report that has 3 parameters representing different types of services for which I am displaying all the companies and their details that match those parameters in a tablix under each Textbox heading.
The problem is that I am displaying the value of selected parameter in each heading using the expression:
="SERVICE1: " & First(Fields!Service1.Value, "dsServices")
When the DataSet resultset returns no rows, the parameter part of the heading is empty but when row are returned, the heading is as I want it (ex: "SERVICE1: Some sub service category here"). I want the full heading to show up even if there are no rows to display. How do I retain all of the heading? for the record I am using NoRowsMessage property when I want the tablix to be hidden due to no rows returned. Again, I still want the headings with the values selected to appear.
I googled to no avail. Thank you for any tip you can suggest.
The reason why your heading is empty, when your dataset returns nothing is because in your expression you are referencing the first record in your "dsServices" dataset.
This is what your expression does : ="SERVICE1: " & First(Fields!Service1.Value, "dsServices")
In your question you mention you have 3 parameters...if you want to reference these parameters then rather include the parameter value in the expression. That expression would like something like this:
="SERVICE1: " & Parameters!Service1.Value)
I'm obviously assuming you have a parameter for each service type. If you do this then your expression no longer becomes dependent on your dataset.

ASP.Net Report Viewer - Same report multiple times with different parameter values

I'm currently working on an ASP.Net WebForms application that allows a user to select an item from a list, which ultimately results in a SSRS report being shown, using Report Viewer 2010 (in server mode). The report has been coded with a parameter #id to allow the report to display the correct data for the selected item.
The reports dataset can return multiple rows where some of the data is displayed in a summary area at the top (not in the header section) for example a textbox would have the expression =FIRST(Fields!Address.Value, "dsMain"). The data returned is denormalized so Address will always be the same value. Which is why using FIRST() works. And the rest of the data is shown in a Tablix with grouping applied etc.
But now I'm looking to change this so users can select multiple items and therefore effectively show the report multiple times, but shown in the same report viewer control. The main requirement is to batch print the reports, so showing it in one report view control is important to allow for one click printing of everything.
Now because I didn't design the report in the first place and because its fairly complex in its layout and the sql that is executed; the sql is geared towards running for one id and not a list of them. I'm looking for options to not have to rewrite the report or the sql.
Is it possible to give the report viewer the id parameter as a list and let the report viewer execute same report for each id passed? - I know report parameter can accept multiple values but this isn't the same since the report will unintelligently pass the first value to my stored procedure but not repeat the report for the other values. Perhaps there's a setting in the report designer that allows it to repeat if it is passed multiple values?
Can someone suggest something else to get this working? Or is my only option to extend the report and sql to accept multiple id's and effectively redesign the report?
Thanks any suggestions or help with this.
The answer is to use sub-reports.
Create a new report that takes a list of ids as a multi valued parameter.
Use that parameter as the dataset for a list control.
Have a subreport inside the list. Report inside the list is your original report.
You can then pass each element of your dataset(your list of parameters) as parameter to the your sub-report.
SSRS will repeat it as your want.

Resources