Changes

Jump to: navigation, search

Create iReport Templates with Subreports

24,599 bytes removed, 21:32, 20 February 2020
no edit summary
__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).
* links between reportsRegardless 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 report* query limiting (reference only?):Step 2 – Add a subreport to the main report* multiple subreports?:Step 3 – Add a parameter to the subreport* re-using subreports:Step 4 – Define the report query for the subreport*passing other parameters:Step 5 – Add subreport parameter to the main report
===Sub-=Step 1 – Create the Main Report===<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-reports, there are 6 basic steps to create a report with sub-reports:</p>=__NOEDITSECTION__
: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 [[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?
<p>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 “Creating [[Create a Basic Report” iReport Template]] section. Below are the instructions:</p><ol><ol type="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>
====Step 2 – Add Subreport to the Main report====__NOEDITSECTION__
====''Step 2 – Add Sub-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 main report. For example, you could include Activity data on a report''====about Land. Below are the instructions to create a subreport:
<p>A Sub-report is a report within a # On the main 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> #From 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''ItemGUID'' so that the subreport can be more easily re-usedoption.#:The window displays the parameters[[Image:IReport AddParameter2. png|center|250px|''Add Parameter'']]
# 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. Below is Typically the instructions on how to define subreport report query will receive the Report Query: # Open the [[Modify an iReport Template#Using Report Query filters|Report Query window]] # From the Report query window, select ImsmaQuery guid from the Query language list.# Enter a Report Query filter using main report via the parameter defined above created in Step 3 and then use it to limit items in the objects according subreport to those linked to the main report object. The most common Report Query filter would be to filter to only limited objects. For example '''''links.toGuid="$P{ItemGUID}"'''''. See Below is the table below for other combinations of Report Query filters to use instructions on subreports.# Click '''OK'''. :The Report query window closes. # Save the the subreport. {| class="wikitable"|-! Main Report!! Subreport can be !! Value how 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 define 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|}report query:
# Open the [[Modify an iReport Template#Using Report Query filters|report query window]].# 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====Step 5 – Add "$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|Possible Subreport Parameter to Main Report====Relationships]] section below.# Click '''OK'''. The report query window closes. # Save the subreport.
We created a parameter on ====Step 5 – Link the sub-report to connect Subreport to the Main report in Step 4Report====__NOEDITSECTION__Now that both the main and the subreport 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 link the parameter you need for 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:iRepStep06.png|center|500px|''Step 6 – Repeat Step 2-5 for additional sub-reports.'']]====Step 6 – Repeat Step 2-5 for additional sub-reports.====__NOEDITSECTION__
<p>You can have multiple sub-reports in one Main are now ready to run your main report. To add more sub-reports to Running (i.e. previewing) the Main main report, just repeat Step 2 to Step 5.</p><p>Once you have all will automatically run the sub-reports created for your Main reportsubreport(s) as well, you can compile and run your Main report.</p><p>Below is the table listing typical parameters required for both Main report and Sub-reportdata from the main as well as from the subreport(s) will be included in the output.</p>
==Kinds of Subreports==__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>The following section ===Location relationship subreports===__NOEDITSECTION__Because each of the Advance Reports chapter discusses relationships between Items main items in IMSMA {{IMSMANG}}, Accident, Activity, Assistance, Education, Land, QM, and also provides instructions 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 how 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 create based on the '''''location guid''''' field. When creating a specific report/sub-reportswhere 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.</p>guid = "$P{parametername}"
==Reports on Items with a Direct Relationship==__NOEDITSECTION__<p>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 of another item. This type guid 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.
===Country Structure Areas and Associated LocationsLink relationship subreports===__NOEDITSECTION__Although 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 location must victim may be associated with to an accident in a country structure areaparticular 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 process for creating a report of locations in a country structure area on an item and its linked items is very similar to the process for creating a basic reporton 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 location data source contains a field subreport would return the records for each country structure area the particular item that is defined linked to the primary item. The key difference is the query used in your IMSMA databasethe subreport.
To create a report that lists locations within a country structure area: <ol><li>From subreport using the '''File''' menu, select '''Report Wizard'''.</li>link relationship:The iReport Wizard window displays. <li># From the '''Connection/Data Sources''' list, select ''Location Data Source''.</li><li>Click the '''Next''' button.</li>:The window to select the attributes to include in the main report displays. <li>From the Step 2. select fields screen:</li><ol type="a"><li>Select the country structure level(s) on which you would like to list the associated locations.</li><li>Select the fields that you would like to include in the report.</li><li>Click the '''Next''' button.</li>:A window displays the selected fields. </ol><li>Click the '''Next''' button.</li>:The window group the report data displays. <li>From the Group lists, select the country structure level(s) that you selected in step 4a.</li></ol> {{note|Be sure to select the highest country structure level for Group 1, followed by the next highest country structure level for Group 2, and so on.}} <ol start="7"><li>Click pass the '''Next''' button.</li>:The window to select a layout displays. <li>From the window to select a layout:</li><ol type="a"><li>Select the layout option for the report.</li><li>Click the ''guid'Next''' button.</li>:The window displays a message stating that you have successfully created a new report.<li>Click the '''Finish''' button.</li>:The template for your report displays. <li>Click the [[Image:iRepCompile.png]] button to compile the report.</li>:The Save report window displays.<li>Enter a name for the report in the '''File name''' field.</li><li>If there are no compilation errors, you may click the [[Image:iRepRun.png]] button to run the report.</li>:The results of the report display in the iReport JasperViewer window. </ol></ol> ===Location and Associated Items===__NOEDITSECTION__A report of locations and associated items requires you to create an iReport sub-report. A sub-report is a report that is contained within another report. A report on locations and its associated item records will require you to create a report and a sub-report. The main report will contain the data for the location. For each associated item that you would like to include, you will need to create a sub-report.  [[Image:iRep12.png|center|500px|''Figure 12. Location and associated item records'']]<div align="center">''Figure 12. Location and associated item records''</div> All records in IMSMA have a ''guid''. A ''guid'' is a unique value that identifies the record in the IMSMA database. Because the guid is lengthy and comprised of alphanumeric characters, it is typically not a useful value object to display in a report. However, the guid is necessary subreport in determining which item records have a direct relationship.  All accidents, land, activities, educations, QMs, and victims are associated with a single location. The information about the location to which an item record is associated is stored in the location_guid field of the item table and corresponds to the location_guid of the location to which it is associated parameter ([[:Image:iRep03.png|Figure 13]]).  [[Image:iRep13e.png|center|500px|''Figure 13g. location_guid'']]<div align="center">''Figure 13. location_guid''</div> The location_guid field in the item table contains the guid of the location to which the item record is associated. [[:Image:iRep14.png|Figure 14]] shows pass an example of a location and the accident and land that are associated to the location. Notice that the location_guid value (1234-1234) in the accident and land are identical to the location_guid of the location. [[Image:iRep14.png|center|500px|'s 'Figure 14. location_guid example'']]<div align="center">''Figure 14. location_guid example''</div> Creating a report of a location and associated items will require you to complete the following parts::*Part 1: Create a report with location fields:*Part 2: Create a sub-report for the associated item:*Part 3: Add parameters to the sub-report:*Part 4: Create a query the in sub-report to associate the guid to the location report:*Part 5: Add parameters to the location report:*Part 6: Compile and execute the location report ====Part 1. Create a report with location fields====__NOEDITSECTION__The first part of creating a report of locations and their associated items is to create a report of the location fields you would like to include. <ol><li>Ensure that the IMSMA server is started.</li><li>From the '''File''' menu, select '''Report Wizard'''.</li><li>From the '''Connection/Data Sources''' list, select Location Data Source to create in a report of locations.</li><li>Click the parameter called '''NextItemGUID''' button).</li>:The iReport Wizard, Step 2 window displays # Create a list of parameter on the location attributes.<li>Select the fields you would like to include for the location.</li><li>Click the '''Next''' button.</li>:The window displays a list of the attributes that you have selected.<li>Click the '''Next''' button.</li>:The iReport Wizard, Step 3 window displays to allow you to group the report results.<li>Because the report results for this exercise will not need to be grouped, click the Next button.</li>:The iReport Wizard, Step 4 window displays to allow you to select the report layout.<li>Select a layout option.</li><li>Click the '''Next''' button.</li>:The iReport Wizard, Step 5 window displays. <li>Click the '''Finish''' button.</li><li>Save subreport with the report by doing one of the following:</li>*Click the [[Image:iRepSave.png]] icon. *From the File menu, select '''Save'''. ::The Save report window displays.<li>Enter a same name for the report as in the '''File name''' field.</li><li>Click the Save button.</li></ol> ====Part 2. Create a sub-report for the associated item====__NOEDITSECTION__ <table border="#1"><tr><td>The next part of the process for creating a report on locations and its associated items requires you to create a sub-report within the location report.</td></tr></table> <ol><li>Expand the detail section of the report by doing the following:</li><ol type="a"><li>From the '''View''' menu, select '''Bands'''.</li><li>From the left pane, select ''detail''.</li><li># In the '''Band Height''' field that is in the right pane, increase the height of the detail section. At a minimum you will want to double the height.</li></ol></ol> [[Image:iRep15.png|center|500px|''Figure 15. Detail band height'']]<div align="center">''Figure 15. Detail band height''</div> <ol><ol type="a" start="3"><li>Click the '''Apply''' button.</li><li>The height of the band increases based on the value that you entered.</li></ol></ol> [[Image:iRep16.png|center|500px|''Figure 16. Increased detail band'']]<div align="center">''Figure 16. Increased detail band''</div> <ol start="2"><li>Click the [[Image:iRepBand.png]] button to add a sub-report.</li>:The cursor changes to a crosshair. </ol> [[Image:iRep17.png|center|500px|''Figure 17. Sub-report button'']]<div align="center">''Figure 17. Sub-report button''</div> <ol start="3"><li>Click the detail section of the report.</li><li>While holding down the mouse button, drag the cursor to form the rectangle which will contain the sub-report.</li><li>Release the mouse button.</li>:The window below displays. </ol> [[Image:iRep18.png|center|500px|''Figure 18. Sub-report creation'']]<div align="center">''Figure 18. Sub-report creation''</div> <ol start="6"><li>From the window:</li><ol type="a"><li>Select the ''Create a new report'' option.</li><li>Click the '''Next''' button.</li>::The How fill the sub-report screen displays.</ol><li>From the window:</li><ol type="a"><li>Select the data source subreport for the associated related item from the Connection/Data Source list(e. For example, if you are creating a report of locations and its associated accidents, you would select the accident data sourceg.</li><li>Click the '''Next''' button.</li>::The window to select the attributes to include in the report displays. </ol><li>From the window:</li><ol type="a"><li>Select Victim) use the attributes that you would like to include in the report.</li><li>Click the Next button.</li>::The window to select a layout displays.</ol><li>From the window to select a layout:</li><ol type="a"><li>Select the layout option.</li><li>Click the Next button.</li>::The window to specify the sub-report expression displays. </ol><li>From the window to specify the sub-report expression:</li><ol type="a"><li>Enter a name for the sub-report.</li><li>Click the Finish button.</li>::The sub-report displays. </ol></ol> ====Part 3. Add parameters to the sub-report====__NOEDITSECTION__ <table border="1"><tr><td>The next part of the process for creating a report on locations and its associated items is to define parameters that will be used for passing the location id between the sub-report and location report.</td></tr></table> <ol><li>From the '''View''' menu, select '''Parameters'''.</li>:The window displays the parameters. </ol> [[Image:iRep19.png|center|500px|''Figure 19. Window of fields, variables, and parameters'']]<div align="center">''Figure 19. Window of fields, variables, and parameters''</div> <ol><li>Click the '''New''' button.</li>:The Add/modify parameter window displays.<li>From the Add/modify parameter window:</li><ol type="a"><li>In the '''Parameter Name''' field, enter a name for the parameter that will be used to identify the guid for the location.</li></ol></ol> {{note|Although there are no requirements for the parameter name, you should enter a name that is easy to remember and meaningful (for example, ''location'' or ''location_guid''). Make note of this parameter name since it will used in a later step.}} <ol start="4"><ol type="a" start="2"><li>Click the '''OK''' button.</li><li>Close the window that displays the list of all parameters.</li></ol></ol> ====Part 4. Create a query in the sub-report to associate the guid to the location report====__NOEDITSECTION__ {{note|The next part of the process for creating a report on locations and its associated items is to create a query that defines how the location and associated item are related in the IMSMA database. }} <ol><li>From the '''Data''' menu, select '''Report Query'''.</li>:The Report query window displays. <li>From the Report query window:</li><ol type="a"><li>Select ''following ImsmaQuery'' from the '''Query language''' list.</li>syntax<li>In the field below the Query language list, enter location links.guid toGuid= "$P{''ParameterName''parametername}"</li>where ''ParameterName'' is the name of the parameter that you created for the location guid.</ol></ol> [[Image:iRep20.png|center|500px|''Figure 20. Query for report on locations and associated items'']]<div align="center">''Figure 20. Query for report on locations and associated items''</div>
<ol start="3"><ol type="This has the effect of limiting the subreport records to only those records that have a" start="3"><li>Click the '''OKlink''' button.</li>:The Report query window closes. </ol><li>Click to the [[Image:iRepCompile.png]] button to compile guid or object passed from the sub-main report.</li></ol>
===Geospatial relationships=Part 5==__NOEDITSECTION__In addition to Location and Link relationships, many objects in IMSMA can store geospatial/geographic information (i. Add parameters to e. point/polygon information). This relationship with the location sub-geospatial data can be modeled in a report/subreport relationship for any item that has geospatial information associated with it. To include point/polygon information on an object's main report====__NOEDITSECTION__, follow 3 basic steps:
{{note|The next part of the process *Step 1: Create a main report for creating an object with geospatial info*Step 2: Create a report GeospatialInfo subreport on locations and its associated items is to update the location main report, i.e. a report to include using the parameter that will be used to associate GeospatialInfo datasource*Step 3: Create a Geopoint subreport on the location record to item recordsGeospatialInfo report, i.}}e. a report using the Geopoint datasource
<ol><li>Display the location report by doing one of the followingStep 1:</li>*From the '''Window''' menu, select the name of the location Create a main report. for an object with geospatial info*Close the sub-report. *Bring the location Create a main report to the foreground by double-clicking the location report name with an object that is displayed in the Files panehas geospatial information (e. <li>Double-click the sub-report box within the report.</li>:A window displays four tabs (Common, Sub-report, Sub-report (Other), and All)g. <li>From the window:</li><ol type="a"><li>Select the Sub-report (OtherLand) tab.</li><li>Click * Ensure that the '''Add''' button.</li>:The Add/modify parameter window displays. </ol><li>From the Add/modify parameter window:</li><ol type="a"><li>In the 'geospatialInfos''Sub-report Parameter Name''' field, enter the parameter name that you used for the location.</li></ol></ol> {{note|This is added to the parameter that you created previouslymain report.}}
<ol start="5">Step 2: Create a GeospatialInfo subreport on the main report<ol type="* On the main report, add a" start="2">subreport using the '''GeospatialInfo''' datasource<li>In * Pass the '''Default Value Expression''geospatialInfos''''' field, enter to the subreport in a parameter (e.g. GeospatialInfoList). '''Note:''' instead of passing the '''''$F{guid}''.</li><li>Click ''' field to the parameter, the parameter value should be '''OK''$F{geospatialInfos}''''' button.</li></ol><li>Close * In the GeospatialInfo subreport use the window with parameter in the four tabs.</li>following ImsmaQuery language syntax</ol> guid IN $P{parametername}
====Part 6Step 3: Create a Geopoint subreport on the GeospatialInfo report* On the Geospatialinfo subreport, add a subreport using the '''Geopoint''' datasource* Pass the '''''guid''''' field to the subreport in a parameter (e.g. GeospatialGUID). '''Note:''' Pass the '''''$F{guid}''''' field '''NOT''' the '''''$F{geospatialInfos}''''' value. Compile and execute * In the location report====__NOEDITSECTION__Geopoint subreport use the parameter in the following ImsmaQuery language syntax geospatialinfoguid IN $P{parametername}
<ol><li>Ensure that This has the ''Location'' data source effect of limiting the Geospatial records to only those records whose guid is selected from the list.</li><li>Click linked to the [[Image:iRepCompile.png]] button to compile geospatialinfo of the main report.</li><li>Click the [[Image:iRepRunThis is an example of nested reports, i.png]] button to execute the reporte.</li>:The a main report results displays, a subreport, and a sub-subreport. </ol>
==Items with Data Subsets=Other 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.
 
====Part 1. Create a report with attributes for a parent item====__NOEDITSECTION__
The first part of creating a report on a parent and its child items is to create a report which includes the attributes from the parent item you would like to include.
<ol>
<li>Ensure that the IMSMA server is started.</li>
<li>From the '''File''' menu, select '''Report Wizard'''.</li>
<li>From the '''Connection/Data Sources''' list, select the data source for the parent item.</li>
</ol>
 
{{note|Table 3. Parent/child relationships lists the items which may be selected as the parent item for a report.}}
<ol><li>Click the '''Next''' button.</li>:The iReport Wizard, Step 2 window displays a list of attributes for the selected item.<li>Select the attributes you would like to include for the parent item.</li><li>Click the '''Next''' button.</li>:The window displays a list of the attributes that you have selected.<li>Click the '''Next''' button.</li>:The iReport Wizard, Step 3 window displays to allow you to group the report results.<li>Because the report results for this exercise will not need to be grouped, click the '''Next''' button.</li>:The iReport Wizard, Step 4 window displays to allow you to select the report layout.<li>Select a layout option.</li><li>Click the '''Next''' button.</li>:The iReport Wizard, Step 5 window displays. <li>Click the '''Finish''' button.</li><li>Save the report.</li></ol>Needs Assessment
====Part 2. Create a sub-report for the child item====__NOEDITSECTION__The next part of the process for creating a report on a parent and its child items requires you to create a sub-report within the parent item report.  <ol><li>Expand the detail section of the report by doing the following:</li><ol type="a"><li>From the '''View''' menu, select '''Bands'''.</li><li>From the left pane, select ''detail''.</li><li>In the '''Band Height''' field that is in the right pane, increase the height of the detail section. At a minimum you will want to double the height.</li><li>Click the '''Apply''' button.</li>:The height of the band increases based on the value that you entered. </ol></ol> {{note|You may also expand the height of the detail band by dragging the line that separates the detail section of the report and the page footer section down.}} <ol start="2"><li>Click the [[Image:iRepCompile.png]] button to add a sub-report.</li>:The cursor changes to a crosshair. <li>Click the detail section of the report.</li><li>While holding down the mouse button, drag the cursor to form the rectangle which will contain the sub-report.</li><li>Release the mouse button.</li>:The window to create a new report or use an existing one displays. <li>From the window:</li><ol type="a"><li>Select the ''Create a new report'' option.</li><li>Click the '''Next''' button.</li>:The How fill the sub-report screen displays.</ol><li>From the window:</li><ol type="a"><li>Select the data source for the child item from the '''Connection/Data Source''' list.</li><li>Click the '''Next''' button.</li>:The window to select the attributes to include in the report displays. </ol><li>From the window:</li><ol type="a"><li>Select the attributes that you would like to include in the report.</li><li>Click the '''Next''' button.</li>:The window to select a layout displays.</ol><li>From the window to select a layout:</li><ol type="a"><li>Select the layout option.</li><li>Click the '''Next''' button.</li>:The window to specify the sub-report expression displays. </ol><li>From the window to specify the sub-report expression:</li><ol type="a"><li>Enter a name for the sub-report.</li><li>Click the '''Finish''' button.</li>:The sub-report displays.</ol></ol> ====Part 3. Add parameters to the sub-report====__NOEDITSECTION__The next part of the process for creating a report on a parent and its child items is to define parameters that will be used for passing the parent item guid between the sub-report and main report.  <ol><li>From the '''View''' menu, select '''Parameters'''.</li>:The window displays the parameters. <li>Click the '''New''' button.</li>:The Add/modify parameter window displays. <li>From the Add/modify parameter window:</li><ol type="a"><li>In the '''Parameter Name''' field, enter a name for the parameter that will be used to identify the guid for the parent item.</li></ol></ol> {{note|Although there are no requirements for the parameter name, you should enter a name that is easy to remember and meaningful. Make note of this parameter name since it will used in a later step.}} <ol start="4"><ol type="a" start="2"><li>Click the OK button.</li></ol><li>Close the window that displays the list of all parameters.</li></ol> ====Part 4. Create a query in the sub-report to associate the guid to the parent item report====__NOEDITSECTION__The next part of the process for creating a report on locations and its associated items is to create a query that defines how the location and associated item are related in the IMSMA database.  <ol><li>From the '''Data''' menu, select '''Report Query'''.</li>:The Report query window displays. <li>From the Report query window:</li><ol type="a"><li>Select ''ImsmaQuery'' from the '''Query language''' list.</li><li>In the field below the Query language list, enter ''ParentItem''.guid = "$P{''ParameterName''}"</li>where ''ParentItem'' is the default value expression for the parent item and ''ParameterName'' is the name of the parameter that you created for the parent item guid.<li>Click the '''OK''' button.</li>:The Report query window closes. <li>Click the [[Image:iRepCompile.png]] button to compile the sub-report.</li></ol></ol> ====Part 5. Add parameters to the parent report====__NOEDITSECTION__The next part of the process for creating a report on a parent and its child items is to update the parent report to include the guid attribute and parameters that will be used to associate the parent item to the child item.  <ol><li>Display the parent item report by doing one of the following:</li>*From the Window menu, select the name of the report. *Close the sub-report. *Bring the parent item report to the foreground by double-clicking the report name that is displayed in the Files pane. <li>Double-click the sub-report box within the report.</li>:A window displays four tabs (Common, Sub-report, Sub-report (Other), and All). <li>From the window:</li><ol type="a"><li>Select the Sub-report (Other) tab.</li><li>Click the Add button.</li>:The Add/modify parameter window displays. </ol><li>From the Add/modify parameter window:</li><ol type="a"><li>In the Sub-report Parameter Name field, enter the parameter name that you used for the parent item guid.</li></ol></ol> {{note|This is the parameter that you created in step previously.}} <ol start="5"><ol type="a" start="2"><li>In the '''Default Value Expression''' field, enter ''$F{guid}''.</li><li>Click the '''OK''' button.</li></ol><li>Close the window with the four tabs.</li></ol> ====Part 6. Compile and execute the parent item report====__NOEDITSECTION__<ol><li>Ensure that the data source for the parent item is selected from the list.</li><li>Click the [[Image:iRepCompile.png]] button to compile the report.</li><li>Click the [[Image:iRepRun.png]] button to execute the report.</li>:The report results displays.</ol> ==Reports on Linked Items==__NOEDITSECTION__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.  ====Part 1. Create a report with attributes for a primary item=Example Subreport Relationships===__NOEDITSECTION__The first part of creating a report on linked items is to create a report which includes the attributes from the primary item for which you would like to list linked items. <ol><li>Ensure that the IMSMA server is started.</li><li>From the '''File''' menu, select '''Report Wizard'''.</li><li>From the '''Connection/Data Sources''' list, select the data source for the primary item.</li></ol> {{note|Table 3. Parent/child relationships lists the items which may be selected as the primary item for a report.}}class="wikitable" <ol start| align="4center" style="><li>Click the '''Next''' button.</li>background:The iReport Wizard, Step 2 window displays a list of attributes for the selected item.<li>Select the attributes you would like to include for the primary item.</li><li>Click the #f0f0f0;"|'''NextMain Report''' button.</li>| align="center" style="background:The window displays a list of the attributes that you have selected.<li>Click the #f0f0f0;"|'''NextSubreport can be''' button.</li>| align="center" style="background:The iReport Wizard, Step 3 window displays to allow you to group the report results.<li>Because the report results for this exercise will not need to be grouped, click the #f0f0f0;"|'''Next''' button.</li>:The iReport Wizard, Step 4 window displays Value to allow you Pass to select the report layout.<li>Select a layout option.</li><li>Click the '''NextSubreport''' button.</li>| align="center" style="background:The iReport Wizard, Step 5 window displays. <li>Click the #f0f0f0;"|'''FinishReport Query''' button.</li><li>Save the report by doing one of the following:</li>|-*Click the [[Image:iRepSave.png]] icon. *From the File menu, select '''Save'''. ::The Save report window displays.<li>Enter | Location||Any Item with a name for the report in the File name fieldLocation||location guid||location.</li>guid = "$P{ItemGUID}"<li>Click the '''Save''' button.</li></ol> ====Part 2. Create a sub|-report for the linked item====__NOEDITSECTION__The next part of the process for creating a report on | Any linked items requires you to create a sub-report for the item to which the primary item is ||Any linkedItem||Item guid (e.  <ol><li>Expand the detail section of the reportg.</li><li>Click the [[Image:iRepBandLand guid)||links.png]] button to add a sub-report.</li>toGuid="$P{ItemGUID}":The cursor changes to a crosshair. <li>Click the detail section of the report.</li><li>While holding down the mouse button, drag the cursor to form the rectangle which will contain the sub|-report. </li><li>Release the mouse button.</li>:The window to create a new report | Activity||Impact survey or use an existing one displaysInterviewee||Activity guid||hazreduc. <li>From the window:</li><ol typeguid ="a$P{ItemGUID}"><li>Select the ''Create a new report'' option.</li><li>Click the '''Next''' button.</li>:The How fill the sub|-report screen displays.</ol><li>From the window:</li><ol type="a"><li>Select the data source for the child item from the '''Connection/Data Source''' list| Interviewee||Question||interviewee guid||interviewee.</li><li>Click the '''Next''' button.</li>:The window to select the attributes to include in the report displays. </ol><li>From the window:</li><ol typeguid ="a">“$P{ItemGUID}”<li>Select the attributes that you would like to include in the report.</li>|-<li>Click the '''Next''' button| Task||Work Item||Task guid||task.</li>:The window to select a layout displays.</ol><li>From the window to select a layout:</li><ol typeguid ="a$P{ItemGUID}"><li>Select the layout option.</li><li>Click the '''Next''' button.</li>:The window to specify the sub|-report expression displays. </ol>| Any Item with Geospatial information||GeospatialInfo||geoSpatialInfos||guid IN $P{GeospatialInfoList}<li>From the window to specify the sub|-report expression:</li><ol type| Geospatial Info||GeoPoint||GeospatialInfo guid||geospatialInfoGuid ="a$P{ItemGUID}"><li>Enter a name for the sub|-report.</li><li>Click the '''Finish''' button| Any item with devices||Item Device (e.</li>:The sub-report displaysg. </ol></ol> ====Part 3. Add the parameters to the sub-report====__NOEDITSECTION__The next part of the process for creating a report on linked items is to define parameters that will be used for passing the AccidentDevice)||Item guid of the primary item between the sub-report and main report(e.  <ol><li>Click the '''New''' buttong.</li>:The Add/modify parameter window displaysAccident guid)||accident. <li>From the Add/modify parameter window:</li><ol typeguid ="a"><li>In the '''Parameter Name''' field, enter a name for the parameter that will be used to identify the guid for the primary item.</li></ol></ol> $P{{note|Although there are no requirements for the parameter name, you should enter a name that is easy to remember and meaningful. Make note of this parameter name since it will used in a later step.}ItemGUID<ol start="3"><ol typehazard.guid ="a" start="2$P{ItemGUID}"><li>Click the '''OK''' button.</li>|-</ol><li>Close the window that displays the list of all parameters| MRE||MREDetail||MRE guid||mre.</li></ol> ====Part 4. Create a query in the sub-report to associate the guid to the primary report item====__NOEDITSECTION__"$P{ItemGUID}"The next part of the process for creating a report on linked items is to create a query that defines how the primary item and the linked item are related in the IMSMA database. |- <ol><li>From the '''Data''' menu, select '''Report Query'''| Victim||Needs Assessment||victim guid||victim.</li>:The Report query window displays. <li>From the Report query window:</li><ol typeguid="a$P{ItemGUID}"><li>Select ''ImsmaQuery'' from the '''Query language''' list.</li>|-</ol></ol> {{note|The following query is different from the query used when creating a report on items with data subsetsVictim||Cause||victim guid||victim.}} <ol startguid="3$P{ItemGUID}"><ol type="a" start="2">|-<li>In the field below the Query language list, enter links| Assistance||Assistance Given||victimAssistance.guid||victimAssistance.toGuid guid= "$P{''ParameterName''ItemGUID}"</li>where ''ParameterName'' is the name of the parameter that you created for the parent item guid.|-<li>Click the '''OK''' button.</li>:The Report query window closes. </ol><li>Ensure that the Query Executor data source is selected from the | Task||Objective||SQL Field list.</li><li>Click the button to compile the sub-report.</li></ol> ====Part 5. Add attributes and parameters to the main report====__NOEDITSECTION__The next part of the process for creating a report on linked items is to update the main report to include the Objectives||guid attribute and parameters that will be used to associate the primary item to the linked item. IN ($P{SQLList}) <ol><li>Display the main report by doing one of the following:</li>*From the '''Window''' menu, select the name of the report. *Close the sub|-report. *Bring the primary item report to the foreground by double-clicking the report name that is displayed in the Files pane. <li>Double-click the sub-report box within the report.</li>:A window displays four tabs | Work Item||Linked Items (CommonActivity, Sub-reportEducation, Sub-report (Other)QM, and AllAssistance). <li>From the window:</li><ol type="a"><li>Select the Sub-report ||SQL Field list of Items||guid IN (Other$P{SQLList}) tab.</li><li>Click the '''Add''' button.</li>:The Add/modify parameter window displays.</ol><li>From the Add/modify parameter window:</li><ol type="a"><li>In the '''Sub-report Parameter Name''' field, enter the parameter name that you used for the primary report item guid.</li></ol></ol>|}{{note|This is the parameter that you created previously.NavBox HowTo Standardizing Data Analysis and Information Reporting}} <ol start="5"><ol type="a" start="2"><li>In the '''Default Value Expression''' field, enter ''$F{guid}''.</li><li>Click the '''OK''' button.</li></ol><li>Close the window with the four tabs.</li> ====Part 6. Compile and execute the main report====__NOEDITSECTION__<ol><li>Ensure that the data source for the item in the main report is selected from the list.</li><li>Click the [[Image:iRepCompile.png]] button to compile the report.</li><li>Click the [[ImageCategory:iRepRun.pngNAA]] button to execute the report.</li>:The report results displays.</ol> </ol>{{NavBox HowTo use iReport}}
6,632
edits

Navigation menu