Walkthrough: Formula Table Expansion
Construct a formula table based on the 'customers' query, with a multilevel header comprising 'State' and 'City'.
1. Create a new report, and add a table with four rows and two columns.
2. Add the following text to the report's onLoad Handler script to store the results of the 'customers' query:
var q = runQuery('customers');
3. Select cell[1,0]. Right-click and select 'Format' from the context menu. This opens the 'Format' tab at the bottom. Click the Data tab for cell[1,0].
a. In the 'Binding' panel of the Data tab, select the 'Formula' option. Enter the formula 'toList(q['state'])'.
b. In the 'Expansion' panel of the Data tab, set 'Expand Cell' to expand 'Vertical'.
c. In the 'Cell' panel of the Data tab, set the 'Cell Name' to be “st”. The Data tab of the 'Format' panel should still be open.
4. Select cell[2,1].
a. In the 'Binding' panel of the Data tab, select the 'Formula' option. Enter the formula 'toList(q['city@state:$st'])'.
b. In the 'Expansion' panel of the Data tab, set 'Expand Cell' to expand 'Vertical'.
c. In the 'Cell' panel of the Data tab, set the 'Cell Name' to be “ct” and set the 'Row Group' to 'st'.
The table should appear as shown below.
|
|
toList(q['state']) |
|
|
toList(q['city@state:$st']) |
|
|