pub struct PivotByFn;Trait Implementations§
Source§impl Function for PivotByFn
Builds a pivot-style summary matrix from row fields, column fields, and values.
impl Function for PivotByFn
Builds a pivot-style summary matrix from row fields, column fields, and values.
PIVOTBY aggregates intersections of row keys and column keys into a dynamic result grid.
§Remarks
row_fields,col_fields, andvaluesmust have matching row counts.- Aggregation accepts text names (for example
"SUM") or numeric codes. - Optional controls include header handling, row/column totals, and sort order.
- Current implementation uses the first column of
col_fieldsandvaluesfor aggregation. - Invalid setup returns
#VALUE!.
§Examples
title: "Pivot sales by region and quarter"
grid:
A1: "Region"
A2: "East"
A3: "East"
A4: "West"
B1: "Quarter"
B2: "Q1"
B3: "Q2"
B4: "Q1"
C1: "Sales"
C2: 100
C3: 150
C4: 120
formula: '=PIVOTBY(A1:A4,B1:B4,C1:C4,"SUM",3,0,1,0,1)'
expected: "Pivot table with regions as rows and quarters as columns"title: "Pivot with totals enabled"
grid:
A1: "Dept"
A2: "Ops"
A3: "Ops"
A4: "Sales"
B1: "Month"
B2: "Jan"
B3: "Feb"
B4: "Jan"
C1: "Cost"
C2: 40
C3: 35
C4: 55
formula: '=PIVOTBY(A1:A4,B1:B4,C1:C4,"SUM",3,1,1,1,1)'
expected: "Pivot table including row and column totals"related:
- GROUPBY
- SORTBY
- UNIQUE
faq:
- q: "What rows must align in PIVOTBY inputs?"
a: "row_fields, col_fields, and values must share the same row count; otherwise PIVOTBY returns #VALUE!."
- q: "What value range is currently aggregated?"
a: "Current implementation aggregates using the first value column (and first col_fields column for keys), so extra columns are not yet summarized independently."[formualizer-docgen:schema:start] Name: PIVOTBY Type: PivotByFn Min args: 4 Max args: variadic Variadic: true Signature: PIVOTBY(arg1: range@range, arg2: range@range, arg3: range@range, arg4: any@scalar, arg5?: number@scalar, arg6?: number@scalar, arg7?: number@scalar, arg8?: number@scalar, arg9?…: number@scalar) Arg schema: arg1{kinds=range,required=true,shape=range,by_ref=true,coercion=None,max=None,repeating=None,default=false}; arg2{kinds=range,required=true,shape=range,by_ref=true,coercion=None,max=None,repeating=None,default=false}; arg3{kinds=range,required=true,shape=range,by_ref=true,coercion=None,max=None,repeating=None,default=false}; arg4{kinds=any,required=true,shape=scalar,by_ref=false,coercion=None,max=None,repeating=None,default=false}; arg5{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true}; arg6{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true}; arg7{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true}; arg8{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true}; arg9{kinds=number,required=false,shape=scalar,by_ref=false,coercion=NumberLenientText,max=None,repeating=None,default=true} Caps: PURE [formualizer-docgen:schema:end]
fn name(&self) -> &'static str
fn min_args(&self) -> usize
fn variadic(&self) -> bool
fn arg_schema(&self) -> &'static [ArgSchema]
Source§fn eval<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn eval<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
fn namespace(&self) -> &'static str
fn volatile(&self) -> bool
Source§fn aliases(&self) -> &'static [&'static str]
fn aliases(&self) -> &'static [&'static str]
fn function_salt(&self) -> u64
Source§fn eval_reference<'a, 'b, 'c>(
&self,
_args: &'c [ArgumentHandle<'a, 'b>],
_ctx: &dyn FunctionContext<'b>,
) -> Option<Result<ReferenceType, ExcelError>>
fn eval_reference<'a, 'b, 'c>( &self, _args: &'c [ArgumentHandle<'a, 'b>], _ctx: &dyn FunctionContext<'b>, ) -> Option<Result<ReferenceType, ExcelError>>
Source§fn dispatch<'a, 'b, 'c>(
&self,
args: &'c [ArgumentHandle<'a, 'b>],
ctx: &dyn FunctionContext<'b>,
) -> Result<CalcValue<'b>, ExcelError>
fn dispatch<'a, 'b, 'c>( &self, args: &'c [ArgumentHandle<'a, 'b>], ctx: &dyn FunctionContext<'b>, ) -> Result<CalcValue<'b>, ExcelError>
Auto Trait Implementations§
impl Freeze for PivotByFn
impl RefUnwindSafe for PivotByFn
impl Send for PivotByFn
impl Sync for PivotByFn
impl Unpin for PivotByFn
impl UnsafeUnpin for PivotByFn
impl UnwindSafe for PivotByFn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more