QPR Knowledge Base 2017.1

Nested Loops and Custom Tags

Nested Loops and Custom Tags

Previous topic Next topic No directory for this topic  

Nested Loops and Custom Tags

Previous topic Next topic Topic directory requires JavaScript Mail us feedback on this topic!  

In this chapter, we will create a child measure table under each measure in the parent scorecard using nested loops and custom tags.

 

mouse_24 Exercise 6: Create a Table by Repeating a Row.

 

BTN_AR131. Open the designed report document that was created in the Loops topic.
BTN_AR132. Move the cursor between the 'Image placeholder' and '[Selected Objects loop]' tag holder and press Enter to insert a line break.
BTN_AR133. The cursor should now be under the 'Image placeholder' just before the '[Selected Objects loop]' tag holder:

pic_nested_loops_cursor

BTN_AR134. On the QPR tab of the ribbon, click btn_insert_custom_tag Insert Custom Tag. The Insert Custom Tag pane opens.
BTN_AR135. From the 'Tag Type' drop-down menu, select "Repeat Loop".
BTN_AR136. From the 'Loop Type' drop-down menu, select "Custom".
BTN_AR137. In the 'Query' field, type "[{object}].ChildObjects". (This query utilizes the QPR Web Services Foundation Metrics Object Function 'ChildObjects'. See the QPR - Developer's Guide for more information about the QPR Web Services Foundation functions.)
BTN_AR138. In the 'Sort Order' field, type "scorecard.name".
BTN_AR139. In the 'Variable Name' field, type "child". The pane should now look like in the picture below:

pic_nested_loops_insert_custom_tag_pane

BTN_AR1310. Click the Insert Tag button and close the Insert Custom Tag pane by clicking the btn_close_pane button in the top right corner of the pane.
BTN_AR1311. Add a table containing one row and four columns between the tags you just inserted.
BTN_AR1312. Move the cursor inside the first cell in the table:

pic_nested_loops_insert_table

BTN_AR1313. On the QPR tab of the ribbon, click btn_insert_field Insert Field. The Insert Field pane opens.
BTN_AR1314. On the Insert Field pane, select "QPR Metrics Models" from the 'Search From' drop-down menu and expand the hierarchy by clicking the btn_expand_model_hierarchy button.
BTN_AR1315. Select 'Add-In for Microsoft Office Training Model' from the list.
BTN_AR1316. From the 'Search Only' drop-down menu, uncheck everything else but "Variables".
BTN_AR1317. Click the Search button.
BTN_AR1318. From the 'Search Results' section, select "child".
BTN_AR1319. From the 'Fields Available' section, select "Name".
BTN_AR1320. Click the Insert button.
BTN_AR1321. Repeat steps 12 through 20 for each of the other cells, but instead of selecting "Name" select "Value", "Range Icon", and "Trend Icon" for each cell respectively from the 'Fields Available' section:

pic_nested_loops_table_properties

BTN_AR1322. On the Home tab of the ribbon, click the btn_toggle_control_characters Show/Hide Control Characters button so that line breaks etc. can be seen clearly.
BTN_AR1323. Remove extra line breaks from the cells in the table. The table should now look as in the picture below:

pic_nested_loops_line_breaks_removed

BTN_AR1324. Resize the cells in the table giving more space for names and less space for icons.
BTN_AR1325. On the QPR tab of the ribbon, click btn_publish Publish and define a name and a location to the report. Notice how the the measures in each table have the same name. Therefore, in the following steps we'll add the names of the original scorecards to the measures' names.
BTN_AR1326. Place the cursor in the first cell, next to the '[Property: Name]' tag holder.
BTN_AR1327. On the QPR tab of the ribbon, click btn_insert_custom_tag Insert Custom Tag. The Insert Custom Tag pane opens.
BTN_AR1328. From the 'Tag Type' drop-down menu, select "Field".
BTN_AR1329. In the 'Source' field, type "{child}".
BTN_AR1330. In the 'Field Name' field, type "scorecard.name":

pic_insert_loop_scorecard_names

BTN_AR1331. Click Insert Tag.
BTN_AR1332. Add a space between the '[Property:Name]' and '[Property]' tag holders, and add parenthesis around the '[Property]' tag holder:

pic_insert_loop_parenthesis

BTN_AR1333. On the QPR tab of the ribbon, click btn_publish Publish and define a name and a location to the report. The tables should now show the original scorecard's name next to the measure names:

pic_insert_loop_published_final

For a complete example report, see the QPR Add-In for Microsoft Office Training Guide Complete Report.docx found in the <QPR package root>\Tutorials\QPR Add-In for Microsoft Office folder.

For more information, see the Loops and Custom Tags topics in QPR Add-In for Microsoft Office - User's Guide.