Pivot Table Macro

On this page:

Overview

The Pivot Table macro allows you to display a pivot table based on tabular data.

You can define your own types of rendering by adding a pivot-values-rendering user macro.

You can perform calculations on non-numeric character string (such as $20, 4 hours ...) by defining a regular expression and a formula replacement string.

This macro can be easily nested within the Chart Macro to display a chart based on the pivot table generated from your tabular data.

JIRA macro can also be nested within the Pivot Table macro.

Availability

Server version

Parameters

The below table has been automatically generated by Macro Documentation Helpers add-on.

Name
Description
Type
Default Value
Possible Values
ValuesColumn name of the body table(s) used to feed the values of the Pivot tablestring

Type of Calculation *Function (count, sum, average) or custom rendering types used to calculate the values of the Pivot Tableenumcount

count, sum, average, custom types

RowsColumn name of the body table(s) used to feed the rows of the Pivot table.string

ColumnsColumn name of the body table(s) used to feed the columns of the Pivot tablestring

Display Grand Total for RowsAdd a Grand Total column in the Pivot Table and compute a total for each row. This parameter is taken into account only if Rows parameter is not emptybooleanfalse
Display Grand Total for ColumnsAdd a Grand Total row in the Pivot Table and compute a total for each column. This parameter is taken into account only if Columns parameter is not emptybooleanfalse
Display Body TablesThe body table(s) can be displayed 'before' or 'after' the Pivot tableenum
before, after
Regular Expression for ValuesRegular expression used to evaluate the values of the body table in order to replace them by the below replacement string. See examples herestring

Replacement String for ValuesReplacement string corresponding to the above regular expression. The replacement string can be a formula that must follow EvalEx syntax. EvalEx is a handy expression evaluator that allows to evaluate simple mathematical and boolean expressions. See examples here string

Using the Pivot Table Macro

To add the Pivot Table macro to a page:

  1. Edit the page
  2. Prepare a table with an heading row and some data in it. (See Screenshot 1 below)
  3. Use autocomplete to add the Pivot Table macro. (Type '{pivot-table}')
  4. The message "Please insert a table in the body" is displayed. It's because there is no data in the macro body yet (See Screenshot 2 below)
  5. Click Insert to add the Pivot Table macro to your page.
  6. Move your table in the body of the Pivot Table macro  (See Screenshot 3 below)
  7. Click the Pivot Table placeholder and choose Edit. The pivot table appears in the 'Preview Area'. By default, it displays the count of rows of the first column of the body table. (See Screenshot 4 below)
  8. Select a column name in the Values parameter corresponding to a column of your table containing numeric values and change the Type Of Calculation parameter value to sum
  9. Click Refresh in the 'Preview' area, to check that the pivot table sums now the values. (See Screenshot 5 below)
  10. Select a column name in the Rows parameter corresponding to a column of your table
  11. Click Refresh in the 'Preview' area, to check that the pivot table presents the sum of Values Parameter per Rows parameter. (See Screenshot 6 below)
  12. Select a column name in the Columns parameter corresponding to another column of your table
  13. Click Refresh in the 'Preview' area, to check that the pivot table presents the sum of Values Parameter per Rows and per Columns parameters. (See Screenshot 7 below)
  14. Click Save to add the Pivot Table macro to your page.
  15. Click Save again when you are ready to save the page.

Screenshot 1: Example of a table with an heading row and some data in it

Date of SaleSales PersonItem SoldColor of ItemUnits SoldPer Unit PriceTotal Price
10/01/2013ImranNotebookBlack825000200000
10/01/2013ImranLaptopBlack1824000432000
10/02/2013LarryLaptopRed435000140000
10/03/2013ImranMouseRed68505100
10/04/2013LarryNotebookWhite1027000270000
10/05/2013LarryMouseBlack4832
10/05/2013ImranMouseWhite20081600

Screenshot 2: Missing table body message


Screenshot 3: Populate the Pivot Table macro body with a table

Screenshot 4: Pivot Table retrieved 7 records in the body table for the first column Date of Sale


Screenshot 5: Pivot Table summed Per Unit Price column


Screenshot 6: Pivot Table: Sum of Per Unit Price column per Sales Person


Screenshot 7: Pivot Table: Sum of Per Unit Price column per Sales Person per Color of Item


Examples

All the examples below have been automatically generated by Macro Documentation Helpers add-on.

Pivot Table without column and row

Parameters in Macro Browser
Data in Macro Placeholder
Rendered data
Key
Value
ValuesPer Unit Price
Type of Calculation (*)sum
Pivot Table
Date of Sale
Sales Person
Item Sold
Color of Item
Units Sold
Per Unit Price
Total Price
10/01/2013ImranNotebookBlack825000200000
10/01/2013ImranLaptopBlack1824000432000
10/02/2013LarryLaptopRed435000140000
10/03/2013ImranMouseRed68505100
10/04/2013LarryNotebookWhite1027000270000
10/05/2013LarryMouseBlack4832
10/05/2013ImranMouseWhite20081600
Sum of Per Unit Price
111866

Pivot Table with row


Parameters in Macro Browser
Data in Macro Placeholder
Rendered data
Key
Value
ValuesPer Unit Price
Type of Calculation (*)sum
RowsSales Person
Pivot Table
Date of Sale
Sales Person
Item Sold
Color of Item
Units Sold
Per Unit Price
Total Price
10/01/2013ImranNotebookBlack825000200000
10/01/2013ImranLaptopBlack1824000432000
10/02/2013LarryLaptopRed435000140000
10/03/2013ImranMouseRed68505100
10/04/2013LarryNotebookWhite1027000270000
10/05/2013LarryMouseBlack4832
10/05/2013ImranMouseWhite20081600
Sales PersonSum of Per Unit Price
Imran49858
Larry62008



Pivot Table with row and regular expression on values

Parameters in Macro Browser
Data in Macro Placeholder
Rendered datas
Key
Value
ValuesPer Unit Price
Type of Calculation (*)sum
RowsSales Person
Regular Expression for Values(\$)(.*)
Replacement String for Values($2)
Pivot Table
Date of Sale
Sales Person
Item Sold
Color of Item
Units Sold
Per Unit Price
10/01/2013ImranNotebookBlack8$ 2500.45
10/01/2013ImranLaptopBlack18$ 240.56
10/02/2013LarryLaptopRed4$ 35000
10/03/2013ImranMouseRed6$ 850
10/04/2013LarryNotebookWhite10$ 2700.50
10/05/2013LarryMouseBlack4$ 8
10/05/2013ImranMouseWhite200$ 8
Sales Person
Sum of Per Unit Price
Imran3599.01
Larry37708.5

Pivot Table with column and row


Parameters in Macro Browser
Data in Macro Placeholder
Rendered data
Key
Value
ValuesPer Unit Price
Type of Calculation (*)average
RowsSales Person
ColumnsColor of Item
Pivot Table
Date of Sale
Sales Person
Item Sold
Color of Item
Units Sold
Per Unit Price
Total Price
10/01/2013ImranNotebookBlack825000200000
10/01/2013ImranLaptopBlack1824000432000
10/02/2013LarryLaptopRed435000140000
10/03/2013ImranMouseRed68505100
10/04/2013LarryNotebookWhite1027000270000
10/05/2013LarryMouseBlack4832
10/05/2013ImranMouseWhite20081600
Average of Per Unit PriceBlackRedWhite
Imran245008508
Larry83500027000

Pivot Table nested within Chart Macro

Parameters in Macro Browser
Data in Macro Placeholder
Rendered data
Key
Value
Typebar
Show shapestrue
Show Legend?true
Forgivetrue
Chart
Pivot Table
Date of Sale
Sales Person
Item Sold
Color of Item
Units Sold
Per Unit Price
Total Price
10/01/2013ImranNotebookBlack825000200000
10/01/2013ImranLaptopBlack1824000432000
10/02/2013LarryLaptopRed435000140000
10/03/2013ImranMouseRed68505100
10/04/2013LarryNotebookWhite1027000270000
10/05/2013LarryMouseBlack4832
10/05/2013ImranMouseWhite20081600

JIRA macro nested within Pivot Table 

Parameters in Macro Browser
Data in Macro Placeholder
Rendered datas
Key
Value
ValuesKey
Type of Calculation (*)count
RowsAssignee
ColumnsStatus
Pivot Table
JIRA
Count of Key
Done
In Progress
To Do
Seuqra11
admin
12

JIRA macro nested within Pivot Table nested within Chart Macro

Parameters in Macro Browser
Data in Macro Placeholder
Rendered datas
Key
Value
Typebar
Show shapestrue
Show Legend?true
Forgivetrue
Chart
Pivot Table
JIRA

JIRA macro nested within Pivot Table with a regular expression to calculate Original Estimate

Parameters in Macro Browser
Data in Macro Placeholder
Rendered datas
Key
Value
ValuesOriginal Estimate
Type of Calculation (*)sum
RowsPerson
Regular Expression for Values(((\d*)([\.|,]){0,1}(\d*))( ){0,1}(w)){0,1}(\D*){0,1}(((\d*)([\.|,]){0,1}(\d*))( ){0,1}(d)){0,1}(\D*){0,1}(((\d*)([\.|,]){0,1}(\d*))( ){0,1}(h)){0,1}(\D*){0,1}(((\d*)([\.|,]){0,1}(\d*))( ){0,1}(m)){0,1}(\D*){0,1}(((\d*)([\.|,]){0,1}(\d*))( ){0,1}(s)){0,1}(\D*){0,1}
Replacement String for ValuesROUND((0$2 * 5 * 5) + (0$10 * 5) + 0$18 + 0$26/60 + 0$34/3600,0)
Pivot Table
JIRA
Task IdPersonOriginal Estimate
1Imran1 week, 1 day, 1 hour
2Imran2 hours
3Larry1w 1d 1h
4Imran1w, 1d, 1h, 1m, 30s
5Larry12.51w 13.65d, 14.78h, 18.54m, 30.90s
6Larry2 weeks, 5 days, 6 hours
7Imran1 week
Person
Sum of Original Estimate
Imran89
Larry508


Pivot Table with pivot-values-rendering macro

Parameters in Macro Browser
Data in Macro Placeholder
Rendered datas
Key
Value

ValuesItem Sold
Type of Calculation (*)tick
RowsSales Person
ColumnsColor of Item
Pivot Table
Date of Sale
Sales Person
Item Sold
Color of Item
Units Sold
Per Unit Price
Total Price
10/01/2013ImranNotebookBlack825000200000
10/01/2013ImranLaptopBlack1824000432000
10/02/2013LarryLaptopRed435000140000
10/03/2013ImranMouseRed68505100
10/04/2013LarryNotebookWhite1027000270000
Item Sold
BlackRedWhite
Imran(tick)(tick)
Larry
(tick)(tick)