Create pivot table using table

Refer to the following example code to see how to create a pivot table using a table.