Changes

Jump to: navigation, search

Create iReport Templates with Subreports

6,337 bytes added, 21:32, 20 February 2020
no edit summary
==Advanced Reports=={{TOC right}}===Sub-Report=Creating Subreports==__NOEDITSECTION__<p>Sub-A subreport is a report is reports within a report; thus, providing a way to generate a report that includes data on the target IMSMA Item item as well as data on other IMSMA Items items that are associated to the target IMSMA Itemitem. Generally a sub-report subreport is used in a situation where you have one or more sets of data relating to a single IMSMA item. A common use case would be a Location report with multiple details bands of different IMSMA items (HazardLand, Hazard ReductionActivity, Accident, Victim, MREEducation, and QCQM).</p><p>Regardless of what IMSMA data you’re including in your report and sub-reports, there are 6 basic steps to create a report with sub-reports:</p>
Regardless of what IMSMA data you’re including in your report and subreports, there are 5 basic steps to create a report with subreports::Step 1 – Create the Main main report:Step 2 – Add Sub-report a subreport to the Main main report:Step 3 – Add Parameter a parameter to the Sub-reportsubreport:Step 4 – Define Report Query the report query for the Sub-reportsubreport:Step 5 – Add Sub-report Parameter subreport parameter to the Main main report:Step 6 – Repeat Step 2-5 for additional Sub-reports
[[Image:iRepStep01.png|center|500px|''====Step 1 – Create the Main Report'']]====__NOEDITSECTION__
Before creating the main report, you will need to determine what data should be included in your report. For example, if you are creating a report about Land with all the Progress Report data, then the target IMSMA item for your main report should be Land and the target data for your subreport should be Activity assuming that Progress Reports are entered into the system as Activity. Below is a list of questions and things to be considered when designing a report.*What are all the data to be included on the report?*What is the target IMSMA item for the main report? This is the primary data of your report.*What is the target IMSMA item for the subreports? This is the secondary data of your report.*Determine the relationship between the primary data and the secondary data. How did they get reconciled to one another? How are they linked? The main report should be created with the IMSMA item determined to be the primary data of your report. The main report is just a basic report and can be created using the steps provided in the [[Create a Basic iReport Template]] section. ====''Step 1 2 Create Add Subreport to the Main Report''report====__NOEDITSECTION__ Once the main report has been created you can add a subreport to the main report. The intent of the subreport is to bring data from a different but related datasource into the main report. For example, you could include Activity data on a report about Land. Below are the instructions to create a subreport:
# On the main report, from the '''Palette''' pane, select '''Subreport''' and drag it to the desired band on the iReport template (normally this is the '''Detail''' band).#:[[Image:IReportSubReportPalette.png|center|300px|''Subreport Palette'']]<pdiv align="center">Before creating ''Subreport Palette''</div># Release the button and the window below displays.#:[[Image:IReportSubReport1.png|center|500px|''Add Subreport to the main Main report'']]# Click '''Next''' to define a new subreport unless you have an existing report, that you will need would like to determine what data use for subreport.# Select the desired iReport Template to apply (Blank is recommended).#:[[Image:IReportSubReport2.png|center|500px|''Select the desired iReport Template'']]# Select from the '''Connection/Data Source''' list. This should be included on the IMSMA item determined as the secondary data of your report. For example, if you are creating a report about Hazard Land with all the Progress Report dataReports, then the target IMSMA item for your main report “Hazard Reduction” should be Hazard and the target data source for your sub-report should be Hazard Reduction assuming that Progress Reports are entered into the system as Hazard Reductionsubreport. Click Next. Below is a list of questions and things to be considered when designing a report#:[[Image:IReportSubReport3.</p>png|center|500px|''Select the desired datasource'']]*What are all # Select the data attributes to be included on the report?in your subreport. Click '''Next'''.*What is #:[[Image:IReportSubReport4.png|center|500px|''Select the target IMSMA Item desired fields for the Main report? subreport'']]# Select the fields to group by. This step is the primary data of your reportnot required. Click '''Next'''.*What is #:[[Image:Subreport_Group_by.png|center|500px|''Select the target IMSMA Item fields to group by'']]# Enter a name for the sub-reports? This is subreport or use the secondary data of your reportdefault. Choose '''Next'''.*Determine #:[[Image:IReportSubReport5.png|center|500px|''Enter a name for the relationship between subreport'']] # Select '''Use the primary data and the secondary datasame connection used to fill master report'''. Click Finish. How did they get reconciled to one another?#:[[Image:IReportSubReport6.png|center|500px|''Use same connection'']] # The subreport displays.
<p>The Main report should be created with the IMSMA item determined ====Step 3 – Add Parameter to be the primary data of your report. The Main report is just a basic report and can be created using the steps provided in the “Creating a Basic Report” section. Below are the instructions:</p><ol><ol typeSubreport===="a"><li>Create your main report with the IMSMA item determined as the primary data of your report. This is just a basic report.</li><li>Save your main report</li><li>Compile your main report to make sure that it’s error-free.</li></ol></ol>__NOEDITSECTION__
To connect a subreport to the main report, we next need to create a parameter for passing the identification (guid) of the primary IMSMA item between the subreport and the main report. In the '''Report Inspector''' on the subreport, [[Image:iRepStep02.pngModify an iReport Template#Adding a Parameter to an iReport Template|center|500px|''Step 2 – Add Sub-report add a Parameter]] to hold the Main guid of the IMSMA item on the main report. It is recommended to add a fairly generic parameter name such as '']]ItemGUID'' so that the subreport can be more easily re-used.
====# From the Report Inspector, '''right click''' on the '''Parameter''' tree and choose '''Step 2 – Add Sub-report Parameter'''.#: [[Image:IReport AddParameter1.png|center|250px|''Add Parameter'']]# In the '''Properties''' pane, enter a parameter name (e.g. ItemGUID} and edit any other properties. Normally it is not required to edit anything other than the name, you might however want to deselect the '''Use as a prompt''' option.#: [[Image:IReport AddParameter2.png|center|250px|''Add Parameter'']]# Once the Main reportparameter is added it will be available in the '''Report Inspector''' and can be referenced as ''$P{parametername}''====. For example: $P{ItemGUID}
<p>Sub-report is reports within a report. As mentioned earlier, a sub-report should be created with the IMSMA Item determined as the secondary data of the report. Below is the instructions to create a sub-report:</p>====Step 4 – Define Report Query for Subreport====__NOEDITSECTION__
<ol type="The next step is to create a"><li>Increase report query for the size of Detail section of subreport you just created in Step 2 to define how the Main IMSMA item on the main report is related to make room for your sub-report.</li> :'''View''' -> '''Bands''' -> '''detail''' -> '''increase the Band Height''' -> '''Apply''' <li>Click IMSMA item on the [[Image:iRepBandsubreport.png]] button</li><li>Click Typically the detail section of subreport report query will receive the guid from the main report. Hold down via the mouse button parameter created in Step 3 and drag then use it to limit items in the cursor subreport to create a rectangle those linked to define the area of sub-main report. Release Below is the botton and instructions on how to define the window below displays.</li></ol>report query:
# Open the [[Image:iRepBandScreenModify an iReport Template#Using Report Query filters|report query window]].png|center# From the report query window, select '''ImsmaQuery''' from the query language list.# Enter a report query filter using the parameter defined above to limit the objects according to the main report object. The most common report query filter would be to filter to only linked objects. For example '''''links.toGuid="$P{ItemGUID}"'''''. In this step, the Report Query tells the subreport to return only rows that are linked to the guid of the item in the main report via the link table. Other combinations of report query filters can be used on subreports beyond the link table. These are documented in the [[#Example Subreport Relationships|500pxPossible Subreport Relationships]]section below.# Click '''OK'''. The report query window closes. # Save the subreport.
====Step 5 – Link the Subreport to the Main Report====__NOEDITSECTION__Now that both the main and the subreport are ready, the only thing that remains to be done is linking the two together. Below are the instructions to link the two reports:# Make sure you are at the main report by selecting the name of the main report from the tabs at the top of the iReport Designer canvas pane.# Select the subreport box within the main report.#: [[Image:IReportSubReportSelection.png|center|500px|''Select the Subreport on the main report'']]<ol type="a" startdiv align="4center">''Select the Subreport on the main report''<li/div>Click # On the '''NextProperties''' to define a new sub-report unless you have an existing report that you would like to use pane for sub-reportthe Subreport, select the '''Parameter''' selector.#: [[Image:IReport_SubReportProperties.png|center|200px|''Subreport properties'']]<div align="center">''Subreport properties''</lidiv><li>Select from the # '''Add'''Connection/Data Sourcea parameter and type ''' list. This should be exactly the IMSMA item determined as name of the secondary data of your reportsubreport parameter created in step 3''' (e. For example, if you are creating a report about Hazard with Progress Reports, then “Hazard Reduction” should be the data source for the sub-reportg. Click Next''ItemGUID'')#: [[Image:IReport_SubReportParameter.png|center|200px|''Add a parameter'']]<div align="center">''Add a parameter''</lidiv><li>Select # For the '''value expression''', select the attributes appropriate field to be included include in your sub-reportthe parameter. Click '''NextNormally this is ''$F{guid}'''''but other choices are available.</li><li>#: [[Image:IReport_SubReportParameter2.png|center|200px|''Select the layout option. Click appropriate field'']]<div align="center">'Next'Select the field to include in the parameter''.</lidiv><li>Enter a name for the sub-report. # Click Finish. The sub-report displays'''OK''' and close Subreport Parameters window.</li></ol>
[[Image:iRepStep03You are now ready to run your main report. Running (i.e.png|center|500px|''Step 3 – Add Parameter to Sub-previewing) the main report'']]will automatically run the subreport(s) as well, and the data from the main as well as from the subreport(s) will be included in the output.
==Kinds of Subreports==Step 3 – Add Parameter to Sub-report====__NOEDITSECTION__There are three main kinds of relationships in IMSMA on which subreports can be generated from IMSMA data. These are:*Location relationship*Link relationship*Geospatial relationship*Other relationship
<p>To connect ===Location relationship subreports===__NOEDITSECTION__Because each of the main items in {{IMSMANG}}, Accident, Activity, Assistance, Education, Land, QM, and Victim, must be reconciled to a sub-report to Location during the Main data entry phase, each of these objects has a relationship with Location and can thus be a subreport on a Location main report. Since all accidents, we need land, activities, educations, QMs, assistances, and victims are associated with a single location each record knows what location it is related to create a parameter for passing based on the identification ('''''location guid) of ''''' field. When creating a report where the primary IMSMA Item between the sub-main report is a Location and the main report. Below subreport is one of the associated objects the instructions Location's guid is passed to create the subreport in a parameter you need for and the sub-subreport can use a special ImsmaQuery language syntax to limit the subreport data to those associated with the main report's location:</p> location.guid = "$P{parametername}"
<ol start="The location guid field in the subreport item table contains the guid of the location to which the item record is associated. The figure below shows an example of a"><li>At location and the Subaccident and land that are associated to the location. Notice that the location_guid value (1234-report window, select View -> Parameters. :The window displays 1234) in the accident and land are identical to the location_guid of the parameterslocation. </ol>
[[Image:iRep09iRep14.png|center|500px|''Figure 9. Window of fields, variables, and parameterslocation_guid example'']]
<div align="center">
''Figure 9. Window of fields, variables, and parameterslocation_guid example''
</div>
<ol type=To create a subreport using the Location relationship:# From the main "Location"report, pass the location '''''guid''''' to the subreport in a parameter (e.g. in a parameter called '''ItemGUID''').# Create a parameter on the subreport with the same name as in #1.# In the subreport for the related item (e.g. a" startVictim) use the parameter in the following ImsmaQuery language syntax location.guid="2$P{parametername}"><li>Click This has the effect of limiting the subreport records to '''Newonly those records that are associated to the location''' buttonfrom the main report. ===Link relationship subreports===__NOEDITSECTION__In addition to the Location relationship, the main items in {{IMSMANG}} can also be linked with one another during the reconciliation process.</li>This is how, for example, Activities are linked with Land in the {{IMSMANG}} database. Accidents, land, activities, educations, assistances, QMs, and victims may be related to one another via ''links''. For example, a victim may be associated to an accident in a particular land. If these relationships are known, IMSMA users may define these links while reconciling the Data Entry Form. This special relationship can also be modeled in iReport using a report and subreport(s). :The Add/modify parameter window displaysprocess for creating a report on an item and its linked items is similar to the process for creating a report on items with a Location relationship. The item in the main report is the primary item for which you would like to find linked items. The subreport would return the records for the particular item that is linked to the primary item. The key difference is the query used in the subreport.<li>From To create a subreport using the Add/modify parameter windowlink relationship:</li>*Enter “# From the main report, pass the '''''object_guidguid'''''” for of the main report object to the subreport in a parameter (e.g. pass an accident's ''Parameter Name''' where guid''object_guid'' is ' in a parameter called '''ItemGUID''').# Create a parameter on the subreport with the suggested parameter same name as in #1.# In the subreport for the Column D of related item (e.g. a Victim) use the parameter in the Table - Required Parameters for Sub-report belowfollowing ImsmaQuery language syntax links.toGuid="$P{parametername}" *Click This has the effect of limiting the subreport records to only those records that have a '''OKlink''' buttonto the guid or object passed from the main report. <li>Close ===Geospatial relationships===__NOEDITSECTION__In addition to Location and Link relationships, many objects in IMSMA can store geospatial/geographic information (i.e. point/polygon information). This relationship with the window geospatial data can be modeled in a report/subreport relationship for any item that displays the list of all parametershas geospatial information associated with it.<To include point/li></ol>polygon information on an object's main report, follow 3 basic steps:
[[Image*Step 1:iRepStep04Create a main report for an object with geospatial info*Step 2: Create a GeospatialInfo subreport on the main report, i.png|center|500px|''e. a report using the GeospatialInfo datasource*Step 4 – Define Report Query for Sub-3: Create a Geopoint subreport on the GeospatialInfo report, i.e. a report'']]using the Geopoint datasource
====Step 4 – Define Report Query 1: Create a main report for Sub-an object with geospatial info* Create a main report with an object that has geospatial information (e.g. Land).* Ensure that the '''''geospatialInfos''''' field is added to the main report====.
<p>The next step is to create Step 2: Create a GeospatialInfo subreport on the main report query for * On the sub-main report you just created in Step 2 , add a subreport using the '''GeospatialInfo''' datasource* Pass the '''''geospatialInfos''''' field to define how the IMSMA item on subreport in a parameter (e.g. GeospatialInfoList). '''Note:''' instead of passing the Main report is related '''''$F{guid}''''' field to the IMSMA item on parameter, the parameter value should be '''''$F{geospatialInfos}'''''* In the Sub-report. Below is GeospatialInfo subreport use the instructions on how to define parameter in the Report Query:</p>following ImsmaQuery language syntax guid IN $P{parametername}
<ol start="23"><li>At Step 3: Create a Geopoint subreport on the Sub-GeospatialInfo report window, select Data -> Report Query.</li>:The Report query window displays. <li>From * On the Report query window:</li><ol type="Geospatialinfo subreport, add a" start="3">subreport using the '''Geopoint''' datasource<li>Select ImsmaQuery from * Pass the '''''guid''''' field to the Query language listsubreport in a parameter (e.g.</li><li>Enter objectGeospatialGUID).'''Note:''' Pass the '''''$F{guid = “}''''' field '''NOT''' the '''''$PF{object_guidgeospatialInfos}” for ''''' value.* In the ImsmaQuery where object is the object type of the IMSMA item on Geopoint subreport use the Main report - See Column E parameter in the Table - Required Parameters for Sub-report below to determine the following ImsmaQuery string for your Sub-report.</li>language syntax</ol></ol> geospatialinfoguid IN $P{parametername}
[[Image:iRep10This has the effect of limiting the Geospatial records to only those records whose guid is linked to the geospatialinfo of the main report.png|center|500px|''Figure 10This is an example of nested reports, i. Define Report Query for Sube. a main report, a subreport, and a sub-report'']]<div align="center">''Figure 10subreport. Define Report Query for Sub-report''</div>
<ol><ol type="a" start="5">=Other subreport relationships===__NOEDITSECTION__<li>Click '''OK'''Certain items in {{IMSMANG}} have subsets of data that are contained within them.</li>:The Report query window closesFor example, an education may have education details such as the education type, total audience, and percentage of women and men. <li>Click the [[ImageExamples of other subreport relationships include:iRepCompile.png]] button to compile the sub-report.</li></ol></ol>
[[Image:iRepStep05.png<center>{| class="wikitable" width="600"|-|align="center" colspan="2" |500px'''Other subreport relationships'''|-| width="150pt" |''Step 5 – Add Subreport Parameter to Main Report'Parent item']]''| width="450pt" | '''Child item(s)'''|-| Activity || Activity Device
====Step 5 – Add Subreport Parameter to Main Report====Impact survey
<p>We created a parameter on the sub-report to connect to the Main report in Step 3, now we need to create a parameter on the Main report as well. Below is the instructions to create the parameter you need for the Main report:</p><ol type="a"><li>Make sure you are at the Main report by selecting the name of the Main report from the '''Window''' menu or double-clicking the Main report from the Files pane.</li><li>Double-click the sub-report box within the Main report.</li>:A window displays four tabs (Common, Sub-report, Sub-report (Other), and All). <li>Select the Sub-report (Other) tab. Click '''Add'''.</li><li>From the Add/modify parameter window:</li><ol type="i"><li>Enter ''“$P{object_guid}”'' for the '''Sub-report Parameter Name''' field where ''object_guid'' is the parameter name you created in Step 3 for the Sub-report. See Column B in the Table – Required Parameters for Sub-report below to determine the parameter name.</li><li>In the '''Default Value Expression''' field, enter ''$F{guid}''.</li><li>Click '''OK''' and close the windowthe four tabs.</li></ol></ol>Interviewee
[[Image:iRepStep06.png|center|500px|''Step 6 – Repeat Step 2-5 for additional sub-reports.'']]Question
====Step 6 – Repeat Step 2|-5 for additional sub| Education || Education details|-reports.====| Victim || Received Education
<p>You can have multiple sub-reports in one Main report. To add more sub-reports to the Main report, just repeat Step 2 to Step 5.</p><p>Once you have all the sub-reports created for your Main report, you can compile and run your Main report.</p><p>Below is the table listing typical parameters required for both Main report and Sub-report.</p>Needs Assessment
<table border="1">Cause<tr><td>A</td><td>B</td><td>C</td><td>D</td><td>E</td><td>F</td></tr><tr><td>If your Main report is</td><td>Sub-report parameter on Main report</td> <td>Your Sub|-report can be…</td><td>Parameter on Sub-report</td>| Land || Land Device<td>Report Query defined on Sub|-report</td><td>Comments</td></tr><tr><td>Location</td><td>location_guid</td><td>Hazard,Hazard Reduction,Accident,Victim,MRE, orQC</td><td>location_guid</td><td>location.guid = "$P{location_guid}"</td><td>Relationship is defined as “New” to a Location during the reconciliation. </td></tr><tr><td>Hazard, Hazard Reduction,| Accident,Victim,MRE, orQC</td><td>object_guid</td><td>Hazard, Hazard Reduction,|| Accident,DeviceVictim,|-MRE, or| Assistance || Assistance GivenQC</td><td>object_guid</td><td>links.toGuid = "$P{ object_guid}"</td><td>Relationship is defined using “Link” during the reconciliation.</td></tr><tr><td>MRE</td><td>mre_guid</td><td>MRE Detail</td><td>mre_guid</td><td>mre.guid = "$P{mre_guid}"</td>|-<td>Relationship is defined as “New” to a MRE during the reconciliation.</td></tr><tr><td>Hazard Reduction</td><td>hazreduc_guid</td><td>Impact survey,Interviewee,Sector, orVegetation removal</td><td>hazreduc_guid</td><td>hazreduc.guid = "$P{hazreduc_guid}"</td><td>Relationship is defined as “New” to a Hazard Reduction during the reconciliation.</td></tr><tr><td>Interviewee</td><td>interviewee_guid</td><td>Question</td><td>interviewee_guid</td><td>interviewee.guid = “$P{ interviewee_guid}”</td><td>Relationship persisted automatically when Questions are entered for each Interviewee at Field Report.</td></tr><tr><td>Sector</td><td>sector_guid</td><td>Sample</td><td>sector_guid</td><td>sector.guid=”$P{sector_guid}”</td><td>Relationship persisted automatically when Samples are entered for each Sector at Field Report.</td></tr><tr><td>Victim</td><td>victim_guid</td><td>Received MREs</td><td>victim_guid</td><td>victim.guid = "$P{victim_guid}"</td><td>Relationship is defined as “New” to a Victim during the reconciliation.</td></tr><tr><td>| Task</td><td>task_guid</td><td>|| Work Item</td><td>task_guid</td><td>task.guid = "$P{ task_guid|}"</td><td>Relationship is defined when adding a new Work Item to a Task at the Task Editor Window.</td></tr></tablecenter>
<p>The following section of the Advance Reports chapter discusses relationships between Items in IMSMA and also provides instructions process for creating a report on how to create a specific parent item and its children is the same as any other report/sub-reportssubreport relationship.</p>
[[Category===Example Subreport Relationships===__NOEDITSECTION__{| class="wikitable"| align="center" style="background:#f0f0f0;"|'''Main Report'''| align="center" style="background:#f0f0f0;"|'''Subreport can be'''| align="center" style="background:#f0f0f0;"|'''Value to Pass to Subreport'''| align="center" style="background: Administrating IMSMA]] #f0f0f0;"|'''Report Query'''|-| Location||Any Item with a Location||location guid||location.guid = "$P{ItemGUID}"|-| Any linked item||Any linked Item||Item guid (e.g. Land guid)||links.toGuid="$P{ItemGUID}"|-| Activity||Impact survey or Interviewee||Activity guid||hazreduc.guid = "$P{ItemGUID}"|-| Interviewee||Question||interviewee guid||interviewee.guid = “$P{ItemGUID}”|-| Task||Work Item||Task guid||task.guid = "$P{ItemGUID}"|-| Any Item with Geospatial information||GeospatialInfo||geoSpatialInfos||guid IN $P{GeospatialInfoList}|-| Geospatial Info||GeoPoint||GeospatialInfo guid||geospatialInfoGuid = "$P{ItemGUID}"|-| Any item with devices||Item Device (e.g. AccidentDevice)||Item guid (e.g. Accident guid)||accident.guid = "$P{ItemGUID}" hazard.guid = "$P{ItemGUID}"|-| MRE||MREDetail||MRE guid||mre.guid = "$P{ItemGUID}"|-| Victim||Needs Assessment||victim guid||victim.guid="$P{ItemGUID}"|-| Victim||Cause||victim guid||victim.guid="$P{ItemGUID}"|-| Assistance||Assistance Given||victimAssistance.guid||victimAssistance.guid="$P{ItemGUID}"|-| Task||Objective||SQL Field list of Objectives||guid IN ($P{SQLList})|-| Work Item||Linked Items (Activity, Education, QM, Assistance)||SQL Field list of Items||guid IN ($P{SQLList})|}{{NavBox HowTo Standardizing Data Analysis and Information Reporting}}[[Category: i-ReportNAA]]
6,632
edits

Navigation menu