In VertiGIS Studio Reporting, you can display data from a many-to-many relationship by using nested subreports. In this setup, the main report queries the Origin Table, then a parent subreport queries the Relationship Table using the Origin Primary Key from the main report, then a nested subreport queries the Destination Table using the corresponding Destination Foreign Key from the parent subreport.
NOTE: For this to work, it is necessary to include the relationship class as a table in the ArcGIS map or feature service. If the relationship table has not been included, please republish the service so that it is.
Step-by-step Guide
Set up the parent subreport
- Open Reporting Designer and create a new Layer Report. Set the data source to the Origin Table in the relationship.
- Drag-and-drop a Sub-Report control into the Detail band.
- Double-click the new Sub-Report control.
- In the right toolbar, click on the Field List button ( ).
- Next to Parameters, click the "Add parameter" button ( ). This new parameter will hold the value of the Origin Primary Key from the Origin Table, which corresponds to the Origin Foreign Key in the Relationship Table.
- Set the Type based on the field type of your Origin Primary Key and set the Name to something that makes sense to you (e.g. OriginPrimaryKey). Optionally, set the Description. Do not change any of the other properties. Click OK.
- At the top of the Field List panel, click the Add Data Source button.
- Select the Relationship Table for your many-to-many relationship and click Finish.
- Expand the newly added data source and click the "Edit query" button ( ) next to the data table.
- Click Run Query Builder.
- Expand the Query Properties section.
- Click the three dots next to the Filter property.
- Add a condition that binds the Origin Foreign Key in the Relationship Table to a new parameter using the "Equals" operator.
- Expand the Parameters section and select the newly created parameter. Set the Type property to "Expression" and the Value property to the Sub-Report parameter you created earlier (e.g. [Parameters.OriginPrimaryKey] or ?OriginPrimaryKey).
- Complete the Query Builder and the Data Source Wizard.
- Navigate back one level.
- Single-click the Sub-Report control.
- In the right toolbar, click on the Properties button ( ).
- Expand the Data section and then expand Parameter Bindings.
- Click the "Add" button ( ).
- Choose the Parameter Name from the dropdown and set the Binding to the field from the Origin Table that is used as the Origin Primary Key.
- The parent subreport has been configured. Proceed to configuring the nested subreport.
Set up the nested subreport
- Double-click the recently configured Sub-Report control.
- Drag-and-drop a new Sub-Report control into the Detail band.
- Double-click the new Sub-Report control.
- In the right toolbar, click on the Field List button ( ).
- Next to Parameters, click the "Add parameter" button ( ). This new parameter will hold the value of the Destination Foreign Key from the Relationship Table, which corresponds to the Destination Primary Key in the Destination Table.
- Set the Type based on the field type of your Destination Foreign Key and set the Name to something that makes sense to you (e.g. DestinationForeignKey). Optionally, set the Description. Do not change any of the other properties. Click OK.
- At the top of the Field List panel, click the Add Data Source button.
- Select the Destination Table and click Finish.
- Expand the newly added data source and click the "Edit query" button ( ) next to the data table.
- Click Run Query Builder.
- Expand the Query Properties section.
- Click the three dots next to the Filter property.
- Add a condition that binds the Destination Primary Key in the Destination Table to a new parameter using the "Equals" operator.
- Expand the Parameters section and select the newly created parameter. Set the Type property to "Expression" and the Value property to the Sub-Report parameter you created in Step 6 of this section (e.g. [Parameters.DestinationForeignKey] or ?DestinationForeignKey).
- Complete the Query Builder and the Data Source Wizard.
- Navigate back one level.
- Single-click the Sub-Report control.
- In the right toolbar, click on the Properties button ( ).
- Expand the Data section and then expand Parameter Bindings.
- Click the "Add" button ( ).
- Choose the Parameter Name from the dropdown and set the Binding to the field from the Relationship Table that is used as the Destination Foreign Key.
- Double-click the Sub-Report control and configure this nested subreport with all the information you want from the related features.
Comments
0 comments
Article is closed for comments.