Changes

Jump to: navigation, search

Create iReport Templates with Subreports

1,305 bytes added, 17:47, 24 August 2015
m
__FORCETOC__
{{TOC right}}
{{HowTo's==Creating Subreports==__NOEDITSECTION__|[[Start and Configure i-Report|Start and Configure i-Report]]|[[Create A subreport is a report within a report; thus, providing a way to generate a report that includes data on the target IMSMA item as well as data on other IMSMA items that are associated to the target IMSMA item. Generally a subreport is used in a situation where you have one or more sets of data relating to a Basic i-Report Template|Create single IMSMA item. A common use case would be a Basic i-Report Template]]|[[Modify an iReport Template|Modify an iReport Template]]|[[Format an iReport Template|Format an iReport Template]]|[[Create i-Report Templates Location report with Subreports|Create i-Report Templates with Subreports]]|[[Summarize i-Report Template Data|Summarize i-Report Template Data]]}}multiple details bands of different IMSMA items (Land, Activity, Accident, Victim, Education, and QM).
==Sub-Reports==<p>Sub-report is reports within a report; thus, providing a way to generate a report that includes data on the target IMSMA Item as well as data on other IMSMA Items that are associated to the target IMSMA Item. Generally a sub-report 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 (Land, Activity, Accident, Victim, Education, and QM).</p><p>Regardless of what IMSMA data you’re including in your report and sub-reportssubreports, there are 6 5 basic steps to create a report with sub-reportssubreports::Step 1 – Create the main report:Step 2 – Add a subreport to the main report:Step 3 – Add a parameter to the subreport:Step 4 – Define the report query for the subreport:</p>Step 5 – Add subreport parameter to the main report
:====Step 1 – Create the Main report:Step 2 – Add Sub-report to the Main report:Step 3 – Add Parameter to the Sub-report:Step 4 – Define Report Query for the Sub-report:Step 5 – Add Sub-report Parameter to the Main report:Step 6 – Repeat Step 2-5 for additional Sub-reports====__NOEDITSECTION__
[[Image:iRepStep01.png|center|500px|''Step 1 – Create the Main Report'']] ====''Step 1 – Create the Main Report''==== <p>Before creating the main report, you will need to determine what data to should be included on 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 sub-report 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.</p>
*What are all the data to be included on the report?
*What is the target IMSMA Item item for the Main main report? This is the primary data of your report.*What is the target IMSMA Item item for the sub-reportssubreports? 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 main report should be created with the IMSMA item determined to be the primary data of your report. The Main main report is just a basic report and can be created using the steps provided in the [[Create a Basic i-Report iReport Template]] section.
====''Step 2 – Add Subreport to the Main 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 is are the instructions to create a sub-reportsubreport:</p>
# 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'']]<div align="center">''Subreport Palette''</div>
# Release the button and the window below displays.
#:[[Image:IReportSubReport1.png|center|500px|''Add Sub-report Subreport to the Main report'']]# Click '''Next''' to define a new sub-report subreport unless you have an existing report that you would like to use for sub-reportsubreport.
# 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 the IMSMA item determined as the secondary data of your report. For example, if you are creating a report about Land with Progress Reports, then “Activity” “Hazard Reduction” should be the data source for the sub-reportsubreport. Click Next.
#:[[Image:IReportSubReport3.png|center|500px|''Select the desired datasource'']]
# Select the attributes to be included in your sub-reportsubreport. Click '''Next'''.
#:[[Image:IReportSubReport4.png|center|500px|''Select the desired fields for the subreport'']]
# Select the fields to group by. This step is not required. Click '''Next'''.#:[[Image:Subreport_Group_by.png|center|500px|''Select the fields to group by'']]# Enter a name for the sub-report subreport or use the default. Choose '''Next'''.
#:[[Image:IReportSubReport5.png|center|500px|''Enter a name for the subreport'']]
# Select '''Use the same connection use used to fill master report'''. Click Finish.
#:[[Image:IReportSubReport6.png|center|500px|''Use same connection'']]
# The sub-report subreport displays. [[Image:iRepStep03.png|center|500px|''Step 3 – Add Parameter to Sub-report'']]
====Step 3 – Add Parameter to Sub-reportSubreport====__NOEDITSECTION__
<p>To connect a sub-report subreport to the Main main report, we next need to create a parameter for passing the identification (guid) of the primary IMSMA Item item between the sub-report subreport and the main report. Below is In the '''Report Inspector''' on the instructions subreport, [[Modify an iReport Template#Adding a Parameter to an iReport Template|add a Parameter]] to create hold the guid of the IMSMA item on the main report. It is recommended to add a fairly generic parameter you need for name such as ''ItemGUID'' so that the subsubreport can be more easily re-report:</p>used.
# In From the Report Inspector, '''Report Inspectorright click''' on the subreport, '''Parameter''' tree and choose '''Add Parameter'''.#: [[Modify an iReport Template#Adding a Parameter to an iReport TemplateImage:IReport AddParameter1.png|center|250px|add a ''Add Parameter'']] to hold # In the guid of the IMSMA Item on the main report'''Properties''' pane, enter a parameter name (e.g. ItemGUID} and edit any other properties. It Normally it is recommended not required to add a fairly generic parameter edit anything other than the name such , you might however want to deselect the '''Use as a prompt''' option.#: [[Image:IReport AddParameter2.png|center|250px|''ItemGUIDAdd Parameter'' so that the subreport can be more easily re-used.]]
# Once the parameter is added it will be available in the '''Report Inspector''' and can be referenced as ''$P{parametername}''. For example:
$P{ItemGUID}
====Step 4 – Define Report Query for Sub-reportSubreport====__NOEDITSECTION__
The next step is to create a report query for the sub-report subreport you just created in Step 3 2 to define how the IMSMA item on the Main main report is related to the IMSMA item on the subreport. Typically the subreport report query will receive the guid from the main report via the parameter created in Step 3 and then use it to limit items in the subreport to those linked to the main report. Below is the instructions on how to define the Report Queryreport query:
# Open the [[Modify an iReport Template#Using Report Query filters|Report Query report query window]] .# From the Report report query window, select '''ImsmaQuery ''' from the Query query language list.# Enter a Report Query report query filter using the parameter defined above to limit the objects according to the main report object. The most common Report Query report query filter would be to filter to only limited linked objects. For example '''''links.toGuid="$P{ItemGUID}"'''''. See 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 below for other . Other combinations of Report Query report query filters to use can be used on subreportsbeyond the link table. These are documented in the [[#Example Subreport Relationships|Possible Subreport Relationships]] section below.# Click '''OK'''. :The Report report query window closes. # Save the the subreport.
{| class="wikitable"|-! Main Report!! Subreport can be !! Value to Pass to Subreport !! Report Query !! Header text|-| Location || Any Item with a Location|| location guid || location.guid = "$P{ItemGUID}" || Example|-| Land, Activity, Accident, Victim, Assistance, Education, QM, Location || Any linked Item || Item ''guid'' (e.g. Land guid) || links.toGuid="$P{ItemGUID}" || Example |-|Activity || Impact survey, Interviewee, or Vegetation removal || Activity ''guid'' || hazreduc.guid = "$P{ItemGUID}" || Relationship is defined as “New” to an activity during the reconciliation.|-| Interviewee || Question || interviewee ''guid'' || interviewee.guid = “$P{ItemGUID}” || Relationship persisted automatically when Questions are entered for each Interviewee at Data Entry Form.|-| Task || Work Item || Task ''guid'' || task.guid = "$P{ItemGUID}" || Relationship is defined when adding a new Work Item to a Task at the Task Editor Window.|-| Example || Example || Example || Example || Example|} ====Step 5 – Add Link the Subreport Parameter to the Main Report====__NOEDITSECTION__ We created a parameter on Now that both the sub-report to connect to main and the Main report in Step 4subreport are ready, now we need the only thing that remains to create a parameter on be done is linking the Main report as welltwo together. Below is are the instructions to create the parameter you need for link the Main reporttwo reports:# Make sure you are at the Main main report by selecting the name of the Main main report from the tabs at the top of the iReport Designer canvas pane.# Select the subreport box within the Main main report.
#: [[Image:IReportSubReportSelection.png|center|500px|''Select the Subreport on the main report'']]<div align="center">''Select the Subreport on the main report''</div>
# On the '''Properties''' pane for the Subreport, select the '''Parameter''' selector.
#: [[Image:IReport_SubReportProperties.png|center|200px|''Subreport properties'']]<div align="center">''Subreport properties''</div>
# '''Add''' a parameter and give it a type '''exactly the name of the subreport parameter created in step 3''' (e.g. ''ItemGUID'')
#: [[Image:IReport_SubReportParameter.png|center|200px|''Add a parameter'']]<div align="center">''Add a parameter''</div>
# For the '''value expression''', select the appropriate field to include in the parameter. '''Normally this is ''$F{guid}'''''but other choices are available.
#: [[Image:IReport_SubReportParameter2.png|center|200px|''Select the appropriate field'']]<div align="center">''Select the field to include in the parameter''</div>
# Click '''OK''' and close Subreport properties windowsParameters window.
[[Image:iRepStep06You are now ready to run your main report.png|center|500px|''Step 6 – Repeat Step 2-5 for additional sub-reportsRunning (i.'']]====Step 6 – Repeat Step 2-5 for additional sub-reportse. 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.====__NOEDITSECTION__
<p>You ==Kinds of Subreports==__NOEDITSECTION__There are three main kinds of relationships in IMSMA on which subreports can have multiple sub-reports in one Main reportbe generated from IMSMA data. To add more sub-reports to the Main report, just repeat Step 2 to Step 5.</p>These are:*Location relationship*Link relationship*Geospatial relationship<p>Once you have all the sub-reports created for your Main report, you can compile and run your Main report.</p>*Other relationship
==Various Kinds =Location relationship subreports===__NOEDITSECTION__Because each of Subreports=the main items in {{IMSMANG}}, Accident, Activity, Assistance, Education, Land, QM, and Victim, must be reconciled to a Location during the 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, land, activities, educations, QMs, assistances, and victims are associated with a single location each record knows what location it is related to based on the '''''location guid''''' field. When creating a report where the main report is a Location and the subreport is one of the associated objects the Location's guid is passed to the subreport in a parameter and the subreport can use a special ImsmaQuery language syntax to limit the subreport data to those associated with the main report's location: location.guid ="$P{parametername}"
This section discusses relationships between Items in IMSMA and also provides instructions on how to create a specific report/sub-reports. The reports discussed so far location guid field in this training module have been based on a single data source. In this part of the training module, you will learn to create more complex reports that reference multiple data sources. Some items are dependent on subreport item table contains the existence guid of another item. This type of relationship is referred to as a direct relationship. For example, an accident, land, activity, education, QM, or victim has a direct relationship to the location to which it the item record is associated. The figure below shows an example of a location and the accident, and land, activity, education, QM, or victim cannot exist unless it is that are associated with a to the location. This direct relationship is enforced Notice that the location_guid value (1234-1234) in IMSMA via the reconciliation processaccident and land are identical to the location_guid of the location.</p>
[[Image:iRep11iRep14.png|center|500px|''Figure 11. Location and item records directly associated with itlocation_guid example'']]
<div align="center">
''Figure 11. Location and item records directly associated with itlocation_guid example''
</div>
Direct relationships also exist when subsets of data are contained within an itemTo 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'''). For example, an education may have education details such # Create a parameter on the subreport with the same name as in #1.# In the education type, total audience, and percentage of women and mensubreport for the related item (e.g. The education details data requires a Victim) use the education to existparameter in the following ImsmaQuery language syntax location. guid="$P{parametername}"
The following sections will describe This has the process for creating reports on items effect of limiting the subreport records to '''only those records that have a direct relationship between themare associated to the location''' from the main report.
===Location and Associated ItemsLink relationship subreports===__NOEDITSECTION__A report of locations In addition to the Location relationship, the main items in {{IMSMANG}} can also be linked with one another during the reconciliation process. 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 items requires you to create 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 sub-using a reportand subreport(s). A sub-report is The process for creating a report that is contained within another report. A report on locations an item and its associated item records will require you linked items is similar to create the process for creating a report and on items with a sub-reportLocation relationship. The item in the main report will contain is the data primary item for the location. For each associated item that which you would like to include, you will need find linked items. The subreport would return the records for the particular item that is linked to create a sub-reportthe primary item. The key difference is the query used in the subreport.
[[ImageTo create a subreport using the link relationship:iRep12# From the main report, pass the '''''guid''''' of the main report object to the subreport in a parameter (e.png|center|500px|g. pass an accident's '''''guid''''' in a parameter called '''ItemGUID''Figure 12'). Location and associated # Create a parameter on the subreport with the same name as in #1.# In the subreport for the related item records'']](e.g. a Victim) use the parameter in the following ImsmaQuery language syntax<div align links.toGuid="center$P{parametername}"> This has the effect of limiting the subreport records to only those records that have a '''link'''Figure 12to the guid or object passed from the main report.  ===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 geospatial data can be modeled in a report/subreport relationship for any item that has geospatial information associated item records'with it. To include point/polygon information on an object's main report, follow 3 basic steps: *Step 1: Create a main report for an object with geospatial info*Step 2: Create a GeospatialInfo subreport on the main report, i.e. a report using the GeospatialInfo datasource</div>*Step 3: Create a Geopoint subreport on the GeospatialInfo report, i.e. a report using the Geopoint datasource
All records in IMSMA have Step 1: Create a main report for an object with geospatial info* Create a main report with an object that has geospatial information (e.g. Land).* Ensure that the '''guid''. A geospatialInfos'''guid'' field is a unique value that identifies the record in the IMSMA database. Because added to the guid is lengthy and comprised of alphanumeric characters, it is typically not a useful value to display in a main report. However, the guid is necessary in determining which item records have a direct relationship.
All accidentsStep 2: Create a GeospatialInfo subreport on the main report* On the main report, land, activities, educations, QMs, and victims are associated with add a single location. The information about subreport using the location to which an item record is associated is stored in '''GeospatialInfo''' datasource* Pass the location_guid '''''geospatialInfos''''' field of the item table and corresponds to the location_guid of the location to which it is associated subreport in a parameter ([[:Image:iRep03e.g.png|Figure 13]]GeospatialInfoList). '''Note:''' instead of passing the '''''$F{guid}''''' field to the parameter, the parameter value should be '''''$F{geospatialInfos}'''''* In the GeospatialInfo subreport use the parameter in the following ImsmaQuery language syntax guid IN $P{parametername}
[[ImageStep 3:iRep13.png|center|500px|Create a Geopoint subreport on the GeospatialInfo report* On the Geospatialinfo subreport, add a subreport using the '''Geopoint'Figure 13. location_guid'']]<div align="center">datasource* Pass the '''''guid'''''Figure 13field to the subreport in a parameter (e.g. GeospatialGUID). location_guid'''Note:''' Pass the '''''$F{guid}''''' field '''NOT''' the '''''$F{geospatialInfos}''''' value.* In the Geopoint subreport use the parameter in the following ImsmaQuery language syntax</div> geospatialinfoguid IN $P{parametername}
The location_guid field in This has the item table contains effect of limiting the Geospatial records to only those records whose guid is linked to the geospatialinfo of the location to which the item record main report. This is associated. [[:Image:iRep14.png|Figure 14]] shows an example of nested reports, i.e. a main report, a location subreport, and the accident and land that are associated to the location. Notice that the location_guid value (1234a sub-1234) in the accident and land are identical to the location_guid of the locationsubreport.
[[Image:iRep14.png|center|500px|''Figure 14. location_guid example'']]<div align="center">''Figure 14. location_guid example''</div>===Items with Data SubsetsOther subreport relationships===__NOEDITSECTION__Certain items in {{IMSMANG}} have subsets of data that are contained within them. For example, an education may have education details such as the education type, total audience, and percentage of women and men. The education details data requires the education to exist. Table 3. Parent/child Examples of other subreport relationships lists the items and the data subsets that depend on them.include:
<center>
{| class="wikitable" width="600"
|-
| align="center" colspan="2" | '''Table 3. Parent/child Other subreport relationships'''
|-
| width="150pt" | '''Parent item'''
| width="450pt" | '''Child item(s) which require the parent item'''
|-
| Activity || Activity Device Impact survey 
Interviewee
Organisation
Question
Vegetation removal|-| Location || AccidentLandActivityEducationQMVictim
|-
| Education || Education details
|-
| Victim || Received Education
|}
</center>
 
The process for creating a report on a parent item and its children is similar to the process for creating a report on locations and their associated items. The key difference is that the main report will contain the attributes of the parent item. The sub-report will contain the attributes for the child item. For example, if you were trying to create a report of educations and their associated education details, the main report would contain the attributes for education and the sub-report would contain the attributes for education details.
Needs Assessment
===Reports on Linked Items===Part 4 of this training module discussed direct relationships—relationships where the parent item must exist in order for the child item to exist. In this part of the training, you will learn about linked relationships. Linked relationships are optional relationships which may exist between items. Unlike direct relationships that are enforced during the IMSMA reconciliation process, links are optional. Accidents, land, activities, educations, and QMs 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. Cause
[[Image:iRep21.png|center-| Land || Land Device|-| Accident || Accident Device|-| Assistance ||500pxAssistance Given|''Figure 21. Direct relationships vs. Links'']]-<div align="center">| Task || Work Item''Figure 21. Direct relationships vs. Links''|}</divcenter>
The process for creating a report on an a parent item and its linked items children is similar to the process for creating a same as any other report on items with a direct /subreport relationship. The item in the main report is the primary item for which you would like to find linked items. The sub-report would return the records for the particular item that is linked to the primary item. The key difference is the query used in the sub-report.
If you would like to report on different items that linked to the item in the main report, you may create a new sub-report for each linked item. For example, to create a report of land and the accidents and activities that are linked to those land, you would create the main report on land. This report would then contain a sub-report to list linked accidents, and another sub-report to list linked activities. ==Advanced Subreports=Example Subreport Relationships===__NOEDITSECTION__{| class="wikitable"| align="center" style=Using Multiple Subreports in one "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:#f0f0f0;"|'''Report Query'''|-| Location||Any Item with a Location||location guid||location.guid =Reusing Subreports"$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 =Passing other parameters to subreports"$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 use iReportStandardizing Data Analysis and Information Reporting}}[[Category:VIE]]
6,632
edits

Navigation menu