{eval-data}
Plugin: Scaffolding Plugin
Allows for the evaluation of mathematical expressions using data set inside a scaffold.
Usage
{eval-data:Name}expression{eval-data}
Parameters
| Name | Required | Default | Description |
|---|---|---|---|
| [default]/name | | The name of the field the evaluated result will be stored in. | |
| format | | The format the resulting number should be converted to. Follows the standard java.text.DecimalFormat rules. |
Functions
There are some special functions available:
- round([number], [places]) - rounds the number to the amount of specified decimal places.
- sumtable([table], [column]) - sums all rows for the column in the specified table. Put quotes around the table and column names.
- avgtable([table], [column]) - averages all rows for the column in the specified table. Put quotes around the table and column names.
Examples
Basic Mathematics
The following example simply calculates the value of a fraction.
Numerator: {number-data:Numerator|decimal=true}1{number-data}
Denominator: {number-data:Denominator|decimal=true}2{number-data}
Result: {eval-data:Result|format=#0.0}${Numerator}/${Denominator}{eval-data}
Percentage: {eval-data:Percentage|format=##0\%}round(${Result} * 100, 0){eval-data}
Working with tables
This example
{table-data:Values}
|| Name || Value ||
| {text-data:Name}{text-data} | {number-data:Value}{number-data} |
{table-data}
Sum: {eval-data:Sum}sumtable("Values", "Value"){eval-data}
Average: {eval-data:Average}avgtable("Values", "Value"){eval-data}
Notes
- The actual expression being evaluated goes inside the macro content. Other fields in the same context can be referenced in the calculation. See the example scaffold below for more details.
Discussions