A pivot table is a table that displays one metric value for two dimensions. The rows of
the table represent one dimension and the columns another.
This filter can pivot any report by any dimension as long as either:
- the pivot-by dimension is the dimension of the report's subtable
- or, the pivot-by dimension has an associated report, and the report to pivot has a dimension with
a segment
Reports are pivoted by iterating over the rows of the report, fetching the pivot-by report
for the current row, and setting the columns of row to the rows of the pivot-by report. For example:
to pivot Referrers.getKeywords by UserCountry.City, we first loop through the Referrers.getKeywords
report's rows. For each row, we take the label (which is the referrer keyword), and get the
UserCountry.getCity report using the referrerKeyword=... segment. If the row's label were 'abcdefg',
we would use the 'referrerKeyword==abcdefg' segment.
The UserCountry.getCity report we find is the report on visits by country, but only for the visits
for the specific row. We take this report's row labels and add them as columns for the Referrers.getKeywords
table.
Implementation details:
Fetching intersected table can be done by segment or subtable. If the requested pivot by
dimension is the report's subtable dimension, then the subtable is used regardless, since it
is much faster than fetching by segment.
Also, by default, fetching by segment is disabled in the config (see the
'[General] pivot_by_filter_enable_fetch_by_segment' option).