Skip to main content

Module pivot_calc

Module pivot_calc 

Source
Expand description

Calculated PivotTable fields: a formula over other fields (=Sales*0.1, ='Unit Price'*Units, =IF(Units>0,Sales/Units,0)).

As Microsoft documents for Excel, the formula operates on the sums of the fields it names for each report cell (items, subtotals and grand totals alike), not record by record: for =Sales*1.2 a cell shows 1.2 × the sum of Sales of that cell’s records. Fields are written bare (Sales) or in single quotes ('Unit Price'); cell references and defined names are not allowed. A calculated field may use other calculated fields; a cycle evaluates to #REF!.

Structs§

CalcSet
A PivotTable’s calculated fields, compiled against its source headers.
Compiled
A parsed formula: field names replaced by placeholder names __pcf0, __pcf1, … in the order of refs.

Constants§

MAX_CALC_FIELDS
Most calculated fields per PivotTable.
MAX_FORMULA_LEN
Longest formula accepted.

Functions§

compile
Parses a calculated-field formula. field maps a written name to the canonical name of a source or calculated field.
eval
Evaluates a compiled formula with the given field values (in refs order).