===Sub-Report===__NOEDITSECTION__
<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>
[[Image:iRepStep01.png|center|500px|''Step 1 – Create the Main Report'']]
====''Step 1 – Create the Main Report''====__NOEDITSECTION__
<p>Before creating the main report, you will need to determine what data to be included on 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 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>
[[Image:iRepStep02.png|center|500px|''Step 2 – Add Sub-report to the Main report'']]
====''Step 2 – Add Sub-report to the Main report''====__NOEDITSECTION__
<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>
[[Image:iRepStep03.png|center|500px|''Step 3 – Add Parameter to Sub-report'']]
====Step 3 – Add Parameter to Sub-report====__NOEDITSECTION__
<p>To connect a sub-report to the Main report, we need to create a parameter for passing the identification (guid) of the primary IMSMA Item between the sub-report and the main report. Below is the instructions to create the parameter you need for the sub-report:</p>
[[Image:iRepStep04.png|center|500px|''Step 4 – Define Report Query for Sub-report'']]
====Step 4 – Define Report Query for Sub-report====__NOEDITSECTION__
<p>The next step is to create a report query for the sub-report you just created in Step 2 to define how the IMSMA item on the Main report is related to the IMSMA item on the Sub-report. Below is the instructions on how to define the Report Query:</p>
[[Image:iRepStep05.png|center|500px|''Step 5 – Add Subreport Parameter to Main Report'']]
====Step 5 – Add Subreport Parameter to Main Report====__NOEDITSECTION__
<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>
[[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 report. To add more sub-reports to the Main report, just repeat Step 2 to Step 5.</p>
<p>The following section of the Advance Reports chapter discusses relationships between Items in IMSMA and also provides instructions on how to create a specific report/sub-reports.</p>
==Reports on Items with a Direct Relationship==__NOEDITSECTION__
<p>The reports discussed so far 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 the existence 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 is associated. The accident, land, activity, education, QM, or victim cannot exist unless it is associated with a location. This direct relationship is enforced in IMSMA via the reconciliation process.</p>
The following sections will describe the process for creating reports on items that have a direct relationship between them.
===Country Structure Areas and Associated Locations===__NOEDITSECTION__
Although a location must be associated with a country structure area, the process for creating a report of locations in a country structure area is very similar to a basic report. The location data source contains a field for each country structure area that is defined in your IMSMA database.
:*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>
====Part 2. Create a sub-report for the associated item====__NOEDITSECTION__
<table border="1">
</ol>
====Part 3. Add parameters to the sub-report====__NOEDITSECTION__
<table border="1">
</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>
====Part 5. Add parameters to the location sub-report====__NOEDITSECTION__
{{note|The next part of the process for creating a report on locations and its associated items is to update the location report to include the parameter that will be used to associate the location record to item records.}}
</ol>
====Part 6. Compile and execute the location report====__NOEDITSECTION__
<ol>
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>
</ol>
====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>
====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>
====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>
====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>
====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>
</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, lands, 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.
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 lands and the accidents and activities that are linked to those lands, you would create the main report on lands. 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==== __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>
====Part 2. Create a sub-report for the linked item====__NOEDITSECTION__
The next part of the process for creating a report on linked items requires you to create a sub-report for the item to which the primary item is linked.
</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 guid of the primary item between the sub-report and main report.
</ol>
====Part 4. Create a query in the sub-report to associate the guid to the primary report item====__NOEDITSECTION__
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>
====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 guid attribute and parameters that will be used to associate the primary item to the linked item.
<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>