Page tree

Documentation for Structure version 4.3 and patch releases. Version Index

Skip to end of metadata
Go to start of metadata

All standard aggregate functions are listed on this page.

An aggregate function call contains an expression in curly braces ("{}"), which is calculated for the item and all sub-items (or, in some cases, for other subset of related items in the structure), and then the resulting values are aggregated according to the meaning of the aggregate function.

An aggregate function may have modifiers, which are all listed here.

Aggregation Functions

SUM

Sum calculates numerical total for the values calculated for the item and/or its sub-items.

Note that when the value of the expression under aggregation is not numeric (cannot be converted to number), it is ignored.

If a certain issue (or another kind of item) is included multiple times in the sub-tree, the sum will include the value for that issue only once. This behavior can be overridden by #all modifier.

Accepts modifiers: #all#children#leaves#strict.

COUNT

Count calculates count of defined (or truthy if #truthy modifier is specified) values for the item and/or its sub-items.

If a certain issue (or another kind of item) is included multiple times in the sub-tree, it will be counted only once. This behavior can be overridden by #all modifier.

Accepts modifiers: #all#children#leaves#strict#truthy.

AVG

Avg calculates an average of defined values for the item and/or its sub-items. The result for avg is generally the same as sum/count. Returns nothing in case there are no defined values for {x}.

If a certain issue (or another kind of item) is included multiple times in the sub-tree, the average value will include the value for that issue only once. This behavior can be overridden by #all modifier.

Accepts modifiers: #all#children#leaves#strict.

MAX

Max calculates maximum of defined values for the item and/or its sub-items. Numeric, date, duration and text fields can be compared. Text fields are compared lexicographically.

Accepts modifiers: #children#leaves#strict.

MIN

Min calculates minimum of defined values for the item and/or its sub-items. Numeric, date, duration and text fields can be compared. Text fields are compared lexicographically.

Accepts modifiers: #children#leaves#strict.

JOIN

Join calculates concatenation of strings. If current row has children and #subtree modifier is set, join appends values for children wrapping them into characters (braces by default). Wrapping characters can be set by #beforeChildren and #afterChildren (see example for #subtree to see how it works). By default it joins all parent string values from root to self value.

Accepts modifiers: #ancestors#subtree#children#leaves#strict#reverse#separator#beforeChildren#afterChildren#fromDepth#toDepth.

PARENT

Parent extracts value from the parent row or from ancestor row by specified depth.

Accepts modifier: #depth

Aggregation Modifiers

#all

When this modifier is accessible aggregation function applies to distinct items by default.

This modifier turns off distinct.

 Example

SUM#all{X}
COUNT#all{X}

Can be used with: sumcountavg.

#truthy

Only count row if subexpression produces truthy value.

 Example

COUNT#truthy{X}

Can be used with: count.

#strict

Do not process current row item as part of aggregation.

Cannot be used together with #children (it implies the same effect), #ancestors (use depth modifiers for that), #leaves (together they're useless).

 Example

JOIN#strict{X}
SUM#strict{X}

Can be used with: sumcountavgjoin, min, max.

#children

Only process direct children of current row.

 Example

JOIN#children{X}
SUM#children{X}

Can be used with: sumcountavgjoin, min, max.

#leaves

Only process leaves of subtree of current row.

 Example

JOIN#leaves{X}
SUM#leaves{X}

Can be used with: sumcountavgjoin, min, max.

#subtree

Process whole subtree of current row. This is default behavior for sumcountavgminmax.

 Example

JOIN#subtree{X}

Can be used with: join.

#ancestors

Only process ancestors of current row. This is default behavior for joinparent.

Can be used with: join.

#reverse

Reverses the order of row processing.

 Example

JOIN#reverse{X}

Can be used with: join.

#separator

Defines separator for string joining. This modifier has string parameter, default is ", ".

 Example

JOIN#separator="->"{X}

Can be used with: join.

#beforeChildren

See #afterChildren.

#afterChildren

Defines exit separator between children and parent rows. This modifier has string parameter, default is "(" for #beforeChildren and ")" for #afterChildren.

 Example

JOIN#subtree#beforeChildren="<{"#afterChildren="}>"{X}

Can be used with: join.

#fromDepth

Specifies position of the row that would be the first in sequence of rows aggregate function takes as an input.

Position is specified by integer parameter denoted as n below.

Positive values mean absolute depth of row in the structure, e.g. n=1 means root.

Negative values mean depth relative to current row, e.g. n=-1 is direct parent.

Default is 1. n shouldn't be 0.

This modifier doesn't work with any tree types except #ancestors.

 Example

JOIN#fromDepth=-1{X}
JOIN#fromDepth=2 {X}

Can be used with: join.

#toDepth

Specifies position of the row that would be the last in sequence of rows aggregate function takes as an input.

Position is specified by integer parameter denoted as n below.

Positive values mean absolute depth of row in the structure, e.g. n=1 means root.

Negative values mean depth relative to current row, e.g. n=-1 is direct parent.

Default is 0. 0 means current row.

This modifier doesn't work with any tree types except #ancestors.

 Example

JOIN#toDepth=-1{X}
JOIN#toDepth=2 {X}

Can be used with: join.

#depth

Denotes the parent that possesses value. This is specified via integer parameter denoted as n below.

Positive values mean absolute depth of row in the structure, e.g. n=1 means root.

Negative values mean depth relative to current row, e.g. n=-1 is direct parent.

Default is -1. n shouldn't be 0.

 Example

PARENT#depth=-1{X}   // default one
PARENT#depth=-2{X}   // "grandparent"
PARENT#depth=1 {X}   // root row
PARENT#depth=2 {X}

Can be used with: parent.