CSV Datasource in Subreport - csv

I'm new to JasperReports and I have a big problem inserting Subreports from CSV. I've been looking for information for 3 days and can not understand what must I do.
I have a dataset named RB1 in csv format, that I need to import to JasperReports. In the main report I have no problems, I can import it and show fields as I want.
The problem arises when I need to insert a subreport with the same database.
I create another report named SUB_1, and link it to the database RB1 as if it was an usual report, and I put the variable COLUMN_0 to be shown in the details section. I previsualize it and it is OK.
I go back to the main report and drag the item SUBREPORT to the summary section and select "select an existing report". I choose the report SUB_1 -> NEXT
I select "use same JDBC connection used to fill the master report" -> NEXT
In the Dataset Parameters I clic ADD and write:
PARAMETER NAME: COLUMN_0
PARAMETER EXPRESSION: $F{COLUMN_0}
What I'm trying to do is to link the variable COLUMN_0 of the main report with the variable COLUMN_0 in the subreport.
Now, when I try to previsualize the report, the subreport does not show.
In the Properties of the Subreport I have:
EXPRESSION: "SUB_1"
PARAMETERS MAP EXPRESSION:
CONNECTION EXPRESSION: $P{REPORT_CONNECTION}
DATA SOURCE EXPRESSION:
What am I doing wrong? I guess that many things, but could not find any answer online with this in detail in a way that I can understand it.

I solved the first part of my problem: I could print data in the subreports from the main report. Or better said, I could half-print some data.
I use an answer to the question I posted, to continue asking about this problem.
I have been thinking and looking for info and I think that the problem now could be because of the indices. The point is that when my subreport is used, there is some data that has been used by the main report, so the subreport seems not to work for the lines that were used by the main report. Is that possible?
If this is the problem, is there any way to make my subreports to work for all data and not just for the ones that are not used in the main report?
Thank you very much!!
I think I am really close to solve it thank to you :D:D

Related

SSRS Subreport disappears after page is changed

I'm using Visual Studio 2019 with SSDT(SQL Server Data Tools) and "Microsoft Reporting Services Projects" to create a SSRS Report. In this Report I have several Subreports to show detail information.
It can happen that one of the subreports shows no additional data. In this case I still want the structure of the Subreport to be shown, like this (table structure with thinner Bordes is the Subreport):
But when I switch to another page and back to this page of the Report, the structure is gone:
This seems to be the case, when there is no information in the Subreport.
There are no visibility properties set, neither in the Subreport nor in the "parent"-Report, so everything should be visible all the time.
Yes it will happen because your sub report does not return anything and hence the blank.
For Testing just try running one of your sub report only (without main report) with parameter which does not return data and you will see your sub report page is completely empty
Now how to solve this issue:
For your sub report:
I would add static table (without datasets) and add it on top of your tablix.
I will add visibility rule to this static table to show only when your datasets does not return data. so that this static is visible only when original subreport data is not available, else you have your subreport data been shown.
This happend because SSRS think should hide the subreport since all the dataset are empty (or the only one you have) so to avoid that in your subreport just add a new dataset with
'select 1 as one'
that will do the job

SSRS Object reference not set to an instance of an object

I'm working on a complex SSRS report that contains a number of subreport, with a total of five levels of nested sub-reports. This is a lot, but necessary due to the complicated nature of the top level report.
I've encountered an odd error with the last subreport I've added:
Warning 1 [rsErrorExecutingSubreport] An error occurred while executing the subreport 'ThingRateQuotaWrapper' (Instance: T0R0S0S1T0R0x0S0): Object reference not set to an instance of an object. C:\Users\mmxxxxxxx\Documents\Visual Studio 2012\ThingsReporting\ThingsReporting\Thing 2014 Consolidated Report.rdl 0 0
The problem here is that when I run the second level report (one of the reports contained in the top level "consolidated" report), everything works fine. But in the top level report, I get this unepected error.
The specific subreport mentioned is four levels down from the top report, so I would expected the second level report to fail if there was an issue, however as just mentioned that works perfectly.
In addition, the RDL and line number mentioned in the error message tells me nothing useful.
I've tried everything I can think of to solve this problem, including deleting, saving, re-inserting and configuring all the subreports from the ThingRateQuotaWrapper upwards. At this point I can think of nothing else to try that makes any sense.
How can a report fail because of a sub report four levels down, when other reports in between work correctly?
Anyone got any ideas or tips? I'm using SQL Server 2012 Business Intelligence and Visual Studio Premium 2012.
I've solved this problem, however I don't entirely understand the solution so I welcome any comments which might expand on it.
My approach was to look through each expression in the set of reports and subreports that make up my consolidated report, looking for any that might fail for any reason. I discovered that the visibility expression for the tablix row which contains the ThingRateQuotaWrapper subreport had the dreaded red squiggly line beneath it.
I believe the cause of the field warning is that the visibility expressed used a dataset other than the primary dataset of the tablix. I reworked the tablix dataset to contain the required column to determine visibility of the subreport, then updated the visibility expression to use the new column in the primary dataset. This fixed the problem.
This issue still impact SSRS in Visual Studio 2017 when renaming a sub-report.
Delete all the object in the \bin\ folder and VS will rebuild it without the error.
In my case, sub report's name had been changed (params and everything were correct) just name had been changed. Lead to this error.
This tends to happen when you change the names on reports. I accomplished this by deleting the .data files in my project directory as this stores the cached data of your reports. Then restart visual studios and the problem should be resolved.
In short:
Delete .DATA files in directory
Restart Visual Studios
Hope this helps.
Thanks
Gavin
To anyone coming to this old thread, I had the exact same error message with the following configuration:
Main report (top parent level report) calls 5 sub report hierarchy deep
The sub report is crashing only when generating from the Main report. Everything is fine when calling from each sub report level (all!) including the sub report itself
Pre-requisite explanation
The business wants me to show either a Bar chart OR a textbox on a dedicated condition.
To avoid empty spaces produced by a ReportItem (my subReport outputing a bar chart) that is hidden, I usually put them inside a Tablix and manage the Row visibility. Like that, no empty spaces is generated !
Old structure causing issue
I have one tablix with two rows :
The first one contains my sub report outputting a bar chart
The second one contains a simple TextBox
The tablix's dataset is a dataset containing the Textbox's text value (and that's the key of the problem !)
New structure fixing the issue
I have now 2 tablix :
One tablix with a dummy dataset ("SELECT 1 as 'Dummy') associated to the tablix. This tablix calls the bar chart's sub report
A second tablix with the same dataset as before (containing the Textbox's text value)
UPDATE 29.06.2022
The solution described above worked without RowVisibility condition. As soon as I've added my expression it fails again :
=IIF(RowNumber("myDataSetName")=0, True, False)
Solution: replace by this condition instead :
=IIF(Count(Fields!MyFieldName.Value) = 0, True, False)
This produces the same : When there the SQL query returns no row, I want to hide it.
It's very strange that SSRS doesn't tell my expression is wrong somehow, and last but not least, it's very weird that the expression works in all report levels except from the Main report. Either an expression is wrong or not.
Looks like a bug in SSRS (SQL Server 2017...maybe it's fixed in SQL Server 2019)

SSRS 2012 Parameter settings

I am creating a report with columns say A,B,C,D,E. I am setting up a drill down on the column A that fetches one more report with Columns
G,H,I,J. The values for the columns G,H,I are from taken the columns A B C. For the column J,I need to pass a parameter explicitly(not from the source report). I set that parameter in
the properties section -> Available Values and mentioned the values. I ran the main report and get the following error
The Parameter J is a missing value
I am pretty much new to the SSRS projects and would be great if I could any assistance on this
It sounds like you are putting parameter J in the wrong place. It doesn't go in the Parameters collection for the main report but in the parameters that are passed to the sub-report.
Right-click the cell with the drill-down and select Text Box Properties.... Choose Action from the left-hand menu and it will show the drill-down report. Under this it says Use these parameters to run the report:
Add the parameters of the sub-report and the values you are passing. You can use an expression to provide the value for parameter J.

SSRS Pull Variables Or Values From Sub Report Into Main Report

I have a main report with several sub reports, each of these with slightly different queries and different ways to show the data.
So, in my situation, I have a textbox that needs to compile data from a few different reports with varying criteria. E.G.
MainReportTextbox =(Sum(columnA, "Main Dataset"))-(SubReportTextBox))
OR
MainReportTextbox =(Sum(columnA, "Main Dataset"))-(subReportVariable))
I saw a few suggested solutions, such as this. Which uses the =[Reports]!MainReport!SubReport!Textbox scheme. The problem is that [Reports] is not a recognized identifier.
I did consider to scrap sub reports and just have everything run on the same main report, but we lose the functionality of being able to use the reports individually, without maintaining the same thing in two places.
So I guess my question is, can you pull variables or element(particularly textboxes in a table) values from sub reports?
If the answer is simply no, please show me some information about why it is no or how it is no from MSDN or a valid source and give some valid counter suggestions.
The links in the question and comments sometimes refer to non-SSRS reports: the syntax [subreport].[Report]![MyFieldName] or [Reports]![YourReportName]![YourSubReportName]![TheValueFromTheSubReportYouWantToReference] are not used in SSRS. It is, however, used in designing MS Access reports, as ojeffrey points out in the discussion you link to.
There is no common method to access data in a subreport. The SSRS model is that parent report data is processed, subreport data is processed, the subreports are rendered, results go back to the parent, then parent is rendered, including the subreport as appropriate. The only data passed between the two is parameters are passed into the the subreport, and rendered output is passed back to the parent. You'll see the that data passed in from the parent must be as report parameters here: http://technet.microsoft.com/en-us/library/ms160348(v=sql.100).aspx
All parameters that are required by the subreport must be included in
the Parameters list. If a required parameter is missing, the subreport
is not displayed correctly in the main report.
For citing authoritative sources:
This discussion sums it up:
No, referring to a report item in a subreport is not allowed.
But that is a bit old, there is also this more recent discussion of work-arounds, provided by Microsoft employee and a MS BI MVP:
You are going to need to replace the subreport item with a data region
like list, table, or matrix to be able to get the proper reference you
are looking for.
[Skipping down to another post]...
Now, it seems you want to calculate the
difference between main report and the subreport. Also, because they
have the different data source, so you cannot use nest
table/matrix/list, right? If so, one workaround I can think of is
pass parameter to the sub report and calculate the total/subtotal in
sub report. I mean, create several hidden/ internal parameters, pass
the values from main report to sub report through parameters and then
calculate the total/subtotal there.
Jeroen's answer to the linked question point towards the direction I would go: use a "Shared Dataset" and enable caching if the dataset is slow to execute. The same dataset execution can then be used for the parent and subreports. This can change the use of parameters: they usually get moved from the SQL query to the filter of the Dataset in the report.
But with the Lookup function introduced in SSRS 2008R2, you can get very flexible with report level joins between datasets.
The details of how I'd design this depend a lot on how much other data needs to get passed back and forth, and how neatly the queries for the reports can be knit together.
Create variable in main report and update it in sub report so you can get value back to main report
ex:
Create formula in main report with name {#Total} place flowing in it
WhilePrintingRecords;
shared Numbervar myTotal := 0;
NOTE : placing ; will not print value and without ; will print value in above example value will not be printed if you want to print value of formula just remove ; from second line ex
WhilePrintingRecords;
shared Numbervar myTotal := 0
now place {#Total} in report header of your main report
now create second formula in sub report where you want to add subtotal to main report formula with name {#addTotal} place following lines in it
WhilePrintingRecords;
shared Numbervar myTotal;
myTotal := myTotal + 200; //or any formula or field
add this formula to place in sub report where you want to add value to total
now create formula in main report to show grand total with name {#showTotal} and place following lines in it
WhilePrintingRecords;
shared Numbervar myTotal;
myTotal
place {#showTotal} in your main report where you want to show this value in report but remember one thing you should place this formula after sub-report.
NOTE : to assign value to variable use := operator

Dynamic subreport in SSRS 2008

I would like to set up a dashboard report in SSRS that contains a bunch of sub reports, but have the reports that are displayed be configurable at run time.
I.E. there could be 4 parameters which represent the names of 4 reports. The report contains 4 reports, and the name of each sub report should be taken from one of the parameters.
It looks like I can't do this, as the 'Use this report as a subreport' property is a dropdown and doesn't provide a way of configuring it as an expression.
Am I right?
Thanks,
Rich
I figure your scenario is just to display one at a time. I needed to do almost the same thing. I have a main report in which I wanted a dynamic number of different subs to be displayed. I solved it like this:
A main report (Main) with a tablix containing a subreport (SubMain), the dataset for Main passes id, subid and subtype. SubMain has no dataset.
And directly in the SubMain I added all my subs (SubDetail) which have their own dataset.
And then I set visibilty for SubDetails depending on type.
/Erik
Normally you'd have to define each subreport in the main report and then set visibility. Or use drill through to emulate navigation.