NIH | National Cancer Institute | NCI Wiki  

Error rendering macro 'rw-search'

null

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 11 Next »

The evaluate data macro allows evaluation of mathematical expressions using data in number data macros.

More information on the evaluate data macro

Basic Mathematics

The following calculates the value of a fraction, initially 1/2.

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}

Observation: The Basic Mathematics example, with the formatting by the java.text.DecimalFormat rules shown in the example from Atlassian, yields the result 5000%. To obtain 50 it was necessary to remove

\%

which is the correct percentage markup and shows the percent sign.

The number data macro establishes the numerator:1
The number data macro establishes the denominator:2The evaluate data macro displays the result:0.5
The evaluate data macro displays the percentage:50

Evaluating Data in Tables

In the Edit Contents view the text data and number data macros display a plus sign with the table. Selecting the plus sign opens the table to accept names of variables and values for them. The evaluate data macros calculate the sum and the average.

An example follows.

{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}

The table data macro contains a table with text data for the name and number data for the value.

Name

Value

Value one

10

Value two

12

The evaluate data macro calculates the sum of the values in the table:22
The evaluate data macro calculates the average of the values in the table:11

  • No labels