Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Document Properties Marker
doctypeapp-macro
overridefalse
Short DescriptionRun calculations on a set of result documents and renders the results.
NameCalculation Macrohide
Short Namehide
Parent
Parent Property
property-nameName
hide
Audience
Name List
doctyperole
render-no-hits-as-blanktrue
property-restrict-value-rangetrue
propertyAudience
empty-as-nonetrue

Subject
Name List
doctypesubject
propertySubject

Categories
Name List
doctypecategory
property-restrict-value-rangetrue
propertyCategories

Tags

Tag List
namesCalculation
propertyTags

hide
Flagshide
Iteration

Iteration
valueproduction

hide
Identifierprojectdoc-calculation-macro
Type
Name List
doctypeapp-macro-type
render-no-hits-as-blanktrue
property-restrict-value-rangetrue
propertyType

Suite
Name List
doctypeapp, app-extension, product-space
render-no-hits-as-blanktrue
property-restrict-value-rangetrue
defaults-toancestor
propertySuite
hide
App Tool
Name List
doctypeapp-tool
render-no-hits-as-blanktrue
property-restrict-value-rangetrue
defaults-toancestor
propertyApp Tool

Since
5
6.
2
0
Deprecated
Removed
Defined Parameters
Name List
doctypeapp-parameter
render-no-hits-as-blanktrue
render-list-as-comma-separated-valuestrue
no-create-linkstrue
property-restrict-value-rangefalse
propertyDefined Parameters
hide
Page Size Support
(tick)

Sort Keyhide
Section
show-titlefalse
titleDescription

Provide a query to select a set of documents and use formulas to calculate a couple of values. One of these values is rendered, the rest can be accessed by additional macros.

The advantage is mainly that calculating a couple of values is calculated with a higher performance.

Section
titleParameters
intro-textThe macro is configured by the following parameters.
Section
titleDoctype(s)
Transclusion
taget-heading-level*
documentDisplay Table Macro
idsDoctype(s)


Transclusion
taget-heading-level*
documentDisplay Table Macro
idsSpace Keys


Transclusion
taget-heading-level*
documentDisplay Table Macro
idsWhere


Section
titleSort By
*
Transclusion
taget-heading-level
documentSort By Property
idsSort By


Section
titleIdentifier
Unique

Optional identifier

of

for the

rendered content

HTML element.

Transclusion
taget-heading-level*
documentDisplay Table Macro
idsExclude Self


Transclusion
taget-heading-level*
documentDisplay Table Macro
idsRestrict to immediate ChildrenMax Hit Count


If checked there is a data attribute added to the rendered element for each line result.

If not checked only the data attributes provided by default are added.
projectdoc-section
titleRender individual Results
transclusion-macro
taget-heading-level*
documentDisplay Table Macro
idsRestrict to immediate Children
Data Attribute
Description
data-projectdoc-result-countProvided by DefaultThe size of the result set. Note that the count of formulas may be smaller than this number if documents in that set do not provide all values required for the Line Document Formula.
data-projectdoc-result-...-NRequires value of trueThe infix for this attribute name (...) is derived from the name of the formula that created it.  The 1-based index of the document that provided the values for it.
data-projectdoc-finalresult-...Provided by DefaultThe final result of the formula with a derived name of the formula is used as a suffix.
Section
titleCSS Classes

If no Document Formula is specified, then no individual results will be calculated and therefore not added.

If not checked only the data attributes provided by default are addedList of HTML class names to be added to the rendered HTML element.
Section
titleRenderRestrict to Favored
Transclusion
documentDisplay Table Macro
idsRestrict to Favored


Section
titleCSS Classes

List of HTML class names to be added to the rendered HTML element.

Render no hits as blank
Section
titleRender

Controls the rendering of the calculated value.

The following values for this parameter are valid.

Parameter ValueDescription
first

Controls the rendering of the calculated value.

The following values for this parameter are valid.

Parameter ValueDescription
firstThe value calculated by the first formula is rendered (default).
none

Nothing is rendered as text, but the element with the data elements still is.

Choose this option if all calculated values are rendered at different locations down the document.

lastThe value calculated by the last first formula is rendered (default).

Choose this option if your formula requires the result of prior defined formulas

Transclusion
none

Nothing is rendered as text, but the element with the data elements still is.

Choose this option if all calculated values are rendered at different locations down the document.

last

The value calculated by the last formula is rendered.

Choose this option if your formula requires the result of prior defined formulas

taget-heading-level*
documentDisplay Table Macro
ids

Transclusion
taget-heading-level*
documentDisplay Table Macro
idsRender no hits as blank


Section
titleNo Hits Result Text

Text to be rendered if no result is available. This overrides the default text.

Section Index
selectName, Short Description, Data Type|, Since|
render-counter-columntrue
Section Compiler by Reference
refDefined Parameters
render-classesparameters-sections, section-compiler-by-reference, parameters
force-showtrue
ids-Description, Details
extract-short-desctrue


Section
titleMacro Body

The body contains the set of formula specifications to calculate values. Each specification of a formula contain a

  1. Name (required),
  2. the Aggregate FormulaFormat,
  3. the FormatDocument Formula,
  4. the Line Result Formula,
  5. the Input Mapping, and
  6. the Output Mapping.

The elements of the specification are provided in any order within the cells of a table.

NameFormat
Line
Document Formula
Aggregate
Result FormulaInput MappingOutput Mapping




Input Format





Output Format







..................
Section
titleName

Identifies the formula and the calculated result.

run the calculations of the formulas. The format is also used to translate the calculated value of the Document Formula and the input value to the Result Formula. Per default the format is also used to parse the input value for the Input Mapping and the output value of the Output Mapping, but only if the column is specified left of the mapping columns.

This format is also called the Formula Format.

The format to parse the input value or to format the output value can be specified with the mapping columns (see below).

The value is a valid number format in Java and defaults to decimal.

Valid values are integer, decimal, currency, and anything that can be parsed by DecimalFormat.

Section
titleAggregate FormulaFormat

The formula format used to aggregate the single values extracted by the Line Formula.

The formula may contain placeholders to values of the document that contains the macro.

The formula may use the placeholders ${SUM} and ${COUNT}. Formulas may use values calculated by formulas defined in a line before it.

PlaceholderDescription
 ${SUM}The sum of values calculated by the Line Formula.
${COUNT}

The count of documents that provided a value for the Line Formula.

For instance if a document does not apply properties for all values of the Line Formula, it does neither contribute to the sum nor to the count.

${NAME_OF_FORMULA}

Where NAME_OF_FORMULA stands for the name of a formula that has been define above the formula that wants to use it.

${NAME_OF_FORMULA$}

The sum value calculated by the formula named NAME_OF_FORMULA.

Caution Box
titleFormat applied to Formulas

Note that the format will be applied to the Document Formula (right column) and the Result Formula (left column) in case the Format column is specified left of them.

The count value calculated by the formula named NAME_OF_FORMULA

.

Section
titleDocument Formula

The formula applied to calculate from each document in the result set.

Use placeholders, like ${Document_Propery_Name} to select values from the documents in the result set

${NAME_OF_FORMULA§}
Example Box
titleExamples for Aggregate Line Formula
Code Block
languagetext
titleUse the sumCalculating story points
${SUM}Story Points} * ${Story Weight}
Code Blockcode
languagetext
titleUse Add up the averageteam sizes
${SUM}/${COUNT}
Section
titleFormat

The format used to translate the calculated value, both of the Aggregate Formula and the Line Formula.

The value is a valid number format in Java and defaults to decimal.

Valid values are integer, decimal, currency, and anything that can be parsed by DecimalFormat.

Section
titleLine Formula

The formula applied to calculate from each document in the result set.

Use placeholders, like ${Document_Propery_Name} to select values from the documents in the result set.

Example Box
titleExamples for Line Formula
Code Block
languagetext
titleCalculating story points
${Story Points} * ${Story Weight}
Code Block
languagetext
titleAdd up the team sizes
${Team Size}
Section
titleInput Mapping
Pending Box
titleNot yet implemented

A table to map an input to be applied to a value read from the documents.

This allows to translate text to double values.

Section
titleOutput Mapping

A table to map a double result value to a textual value, such as the Status Macro.

The first column allows single numeric values and ranges of the format:

Code Block
languagetext
titleRange format
D MIN ; MAX D
TokenDescriptionD

The delimiter D may be either [ or ].

  • If [ is specified for
    • the start value, then the start value is included.
    • the end value, then the end value is excluded.
  • If ] is specified for
    • the start value, then the start value is excluded.
    • the end value, then the end value included.
MIN

The minimum value of the range.

If omitted, the minimum value of the range is the absolute minimum value. Any value smaller than MAX is accepted.

MAX

The maximum value of the range.

If omitted, the maximum value of the range is the absolute maximum value. Any value greater than MIN is accepted.

The defined mappings are processed from top to bottom. The first matching rule provided the representation.

Where one space is shown in the format above there may be any number of spaces, including zero spaces.

Example Box
titleRange examples
Code Block
languagetext
titleEvery value greater than or equal to 10 and smaller than or equal to 30 is accepted
[10;30]
Code Block
languagetext
titleAny number smaller than or equal to 30 is accepted
[;30]
Code Block
languagetext
titleThe number must be exactly 30 - both representations are correct
30

[30;30]
Code Block
languagetext
titleEvery value greater than 10 is accepted
]10;]
Example Box
titleExample configuration for the Output Mapping
Output Mapping[;10] StatuscolourGreytitleGood]10;20] StatuscolourBluetitleGreat]20;]
Status
colourGreen
titleTop notch!
Team Size}

The Document Formula may also access the result of formulas specified in a line prior to this one. Also the results of formulas in Calculation Macros already processed can be accessed.

Example Box
titleExample to reference the Result of a previous Macro

The following example access the result value of a formula named a-formula-name within the Calculation Macro identified by my-macro-id.

Code Block
languagetext
${my-macro-id.a-formula-name}

The following example shows the use of a reference with the Result Formula.

Image Added

The following example shows the use of a reference with the Document Formula (the source table is unchanged from the previous example):

Image Added

The formula name of the reference may be qualified as shown in Result Formula.

Section
titleResult Formula

The formula to be applied to the result of the Document Formulas.

The formula may contain placeholders to values of the document that contains the macro.

The formula may use the placeholders ${SUM}, ${PROD}, ${COUNT}, ${MIN}, and ${MAX}. Formulas may use values calculated by formulas defined in a line before it.

PlaceholderDescription
 ${SUM}The sum of values calculated by the Document Formula.
${PROD}The product of values calculated by the Document Formula.
${MIN}The minimum value calculated by the Document Formula.
${MAX}The maximum value calculated by the Document Formula.
${COUNT}

The count of documents that provided a value for the Document Formula.

For instance if a document does not apply properties for all values of the Document Formula, it does neither contribute to the sum nor to the count.

${AVG}

The average value calculated by the Document Formula.

${name-of-formula_LIT}

The literal value calculated by the formula named name-of-formula. Useful if the calculated value is rendered in an HTML element without value or if the output mapping maps the result values to an array of values.

The value is rendered in the Output Format.

${name-of-formula}

The result value of the formula.

The value is rendered in the Formula Format.

${name-of-formula_SUM}

The sum value calculated by the formula named name-of-formula.

The value is rendered in the Formula Format.

${name-of-formula_PROD}

The product value calculated by the formula named name-of-formula.

The value is rendered in the Formula Format.

${name-of-formula_MIN}

The minimum value calculated by the Document Formula of name-of-formula.

The value is rendered in the Formula Format.

${name-of-formula_MAX}

The maximum value calculated by the Document Formula of name-of-formula.

The value is rendered in the Formula Format.

${name-of-formula_COUNT}

The count value calculated by the formula named name-of-formula.

The value is rendered in the Formula Format.

Example Box
titleExamples for Aggregate Formula
Code Block
languagetext
titleUse the sum
${SUM}
Code Block
languagetext
titleUse the average
${AVG}
Code Block
languagetext
titleSome formula
${PROD}/${COUNT} + 10
Section
titleInput Mapping

A two-column table to map an input to be applied to a value read from the documents.

This allows to translate text to double values and map values provided in the Input Format to be grouped by ranges.

The mapping is applied to the documents of the result set and the document that contains the macro.

The first column contains the value in its normalized rendered form or a range specification. The second value is the numeric value to replace that input form.

The identifier (first column) must be unique within the Input Mapping of a Formula Specification.

Example Box
titleExample configuration for the Input Mapping
Input Mapping
Good2
Great4
Top Notch8

Above the table the Input Format may be specified. If it is not specified, the Input Format defaults to the Formula Format provided with the parameter

In-Document Link
anchorFormat
.

Example Box
titleExample configuration for the Input Mapping with a specific Format
Input Mapping

percent

20%0.2
40%0.4
50%0.5
Example Box
titleExample configuration for the Input Mapping to group Values
Input Mapping
[;10]1
]10;50]2
]50;]3
Caution Box
titleInput Format may clash with Formula Format

If the values are numeric, it is recommended to use an Input Format that is compatible with the Formula Format.

Section
titleOutput Mapping

A two-column table to map a double result value to a textual value, such as the Status Macro. The mapping is applied to the final result of the Result Formula.

The identifier (first column) must be unique within the Output Mapping of a Formula Specification.

The first column allows single numeric values and ranges of the format:

Code Block
languagetext
titleRange format
D MIN ; MAX D
TokenDescription
D

The delimiter D may be either [ or ].

  • If [ is specified for
    • the start value, then the start value is included.
    • the end value, then the end value is excluded.
  • If ] is specified for
    • the start value, then the start value is excluded.
    • the end value, then the end value included.
MIN

The minimum value of the range.

If omitted, the minimum value of the range is the absolute minimum value. Any value smaller than MAX is accepted.

MAX

The maximum value of the range.

If omitted, the maximum value of the range is the absolute maximum value. Any value greater than MIN is accepted.

The defined mappings are processed from top to bottom. The first matching rule provided the representation.

Where one space is shown in the format above there may be any number of spaces, including zero spaces.

Example Box
titleRange examples
Code Block
languagetext
titleEvery value greater than or equal to 10 and smaller than or equal to 30 is accepted
[10;30]
Code Block
languagetext
titleAny number smaller than or equal to 30 is accepted
[;30]
Code Block
languagetext
titleThe number must be exactly 30 - both representations are correct
30

[30;30]
Code Block
languagetext
titleEvery value greater than 10 is accepted
]10;]
Example Box
titleExample configuration for the Output Mapping
Output Mapping
[;10]
Status
colourGrey
titleGood
]10;20]
Status
colourBlue
titleGreat
]20;]
Status
colourGreen
titleTop notch!

Above the table the Output Format may be specified. If it is not specified, the Output Format defaults to the Formula Format provided with the parameter

In-Document Link
anchorFormat
.

Example Box
titleExample configuration for the Output Mapping with specific Format

This example adds the placeholder for the Literal Value of the result. The value is referenced with the placeholder ${LIT}. The label has the suffix  (${LIT}) in the following example.

Output Mapping

percent

[;10%]
Status
colourGrey
titleGood (${LIT})
]10%;20%]
Status
colourBlue
titleGreat (${LIT})
]20%;]
Status
colourGreen
titleTop notch! (${LIT})
Caution Box
titleUppercase Issue

The Status Macro is unfortunately altering the input label to upper case. Therefore only properties with uppercase names can be referenced with this macro.

Details
Section
titleDetails
Section
titleDouble Precision

All calculations are run with double precision, therefore the macro is not suitable for formulas require with discrete values, not allowing limited precision.

For instance use cases requiring calculations based on currencies (integer values) are not supported.

Section
titleAccess Results from other Calculation Macros

To access the result from another Calculation Macro simply prefix the placeholder reference with the identifier of the macro like this:

Code Block
${macro-id.formula-name}

All values of a formula can be accessed as defined in 

In-Document Link
anchorResult Formula
.

Section
titleResult Calculation only

The macro allows to skip the Document Formula and only provide a Result Formula. This way a value can be calculated by the use of results previously calculated - either by a formula above in the table or by other instances of the Calculation Macro specified previously on the same page.

If no Document Formula is specified, the default results, like SUM or AVG are not present, because the formula does not iterate over the documents in the result set. Only the representation, the literal, and the result are provided.

Example Box
titleNo Document Formula

This example shows how the formula named main uses the value of the revelvance-factor formula of the macro result-repo.

NameFormatResult Formula
mainpercent${result-repo.relevance-factor}*2 + 10%
Section
titleData Center Compatibility

To support Atlassian Data Center the macro will limit the number of documents to use in a calculation. If the result set is larger than the maximum number of documents, an error message is rendered.

For more information, please refer to 

Static Document Link
documentLimitations on Query Results
.

Version Box
since6.0

The limitation is checked since version 6.0.

Section
title

Section
titleRelated Macros
Display Table
doctypeapp-macro
render-no-hits-as-blanktrue
render-modedefinition
selectName, Short Description
render-classesrelated-macros-table, display-table, related-macros
where$<Tags>~(${Tags})

...

Section
titleReferences
intro-textEvidence for the information is available by the following references.
Tour
render-no-hits-as-blanktrue
render-as-definition-listtrue
marker-column-property-nameTitle
replace-title-with-nametrue
TitleShort Description
Limitations on Query Results
Section
titleResources
intro-textMore information on this topic is available by the following resources.
Tour
render-no-hits-as-blanktrue
render-as-definition-listtrue
marker-column-property-nameTitle
replace-title-with-nametrue
TitleShort Description