---
title: "metadata-calculate macro"
canonical: "https://support.appfire.com/space/COMALACM/655891311/metadata-calculate%20macro"
format: markdown
---
> Macro (aura-html)

## <span style="color: #091e42">Overview</span>

<span style="color: #091e42">The </span>`metadata-calculate`<span style="color: #091e42"> macro </span><span style="color: #333333">performs calculations using metadata values from matching pages.</span>

<span style="color: #091e42">By default, the macro uses a </span><span style="color: #091e42">**sum**</span><span style="color: #091e42"> function. The macro returns a single value by totalling up any float or integer metadata. This result can be shown directly or can be used as input to another statistics macro, such as the </span><span style="color: #091e42">[Confluence chart ](https://confluence.atlassian.com/doc/chart-macro-163415075.html)</span><span style="color: #000000">[macro](https://confluence.atlassian.com/doc/chart-macro-163415075.html)</span><span style="color: #091e42">.</span>

<span style="color: #091e42">This macro is most useful when presenting several totals in a single chart. The matching pages used for the metadata can be filtered by space key, root page, content label or type of content (page or blog post).</span>

## Parameters

| Parameter | Required | Default | Notes | Version |
| --- | --- | --- | --- | --- |
| value-name (first named parameter) | ![image](media://8de14023-4dea-4aa0-9b7d-225c2c3c9126) |  | <span style="color: #000000">The list of fields (columns) to be included in the report. This can include added metadata and internal metadata.</span> |  |
| `function` |  | `sum` | <span style="color: #091e42">Specifies the function to apply to the matching data:</span><br>- `sum` - returns the sum of each non-empty value (default)
- `average` - returns the average of each non-empty value
- `maximum `- returns the minimum of each non-empty value
- `minimum` - returns the maximum of each non-empty value |  |
| `key` |  | `current space` | <span style="color: #091e42">Limits the content returned to within the space with the given key.</span> |  |
| `root` |  | `current page (@self)` | <span style="color: #000000">Use</span><span style="color: #707070"> </span>`@self`<span style="color: #707070"> </span><span style="color: #000000">for the current page (the default),</span><span style="color: #707070"> </span>`@parent`<span style="color: #707070"> </span><span style="color: #000000">for the parent page, or the name of any page, e.g </span>`MySpace:MyPage`<span style="color: #707070">.</span><br><span style="color: #000000">If this is specified and the pages option is not, then the report is run over only the pages listed here.</span> |  |
| `label` |  |  | Limits the content returned to be with the specified label or labels.<br>A comma-separated list produces ANY pages that match at least one of the listed labels. Using **+** operator for the list returns pages that match** ALL** the labels.   
  
Parentheses can be used to build complex expressions<br>- for example `|label=policy, procedure)+hres|` returns content with  `hres` and also has at least one of `policy` or `procedure`. |  |
| `type` |  |  | <span style="color: #091e42">Specifies which Confluence content types should be considered for a report.</span><br><span style="color: #000000">This feature was based on the Confluence </span>**contentbylabel**<span style="color: #000000"> macro, which has the same attribute.</span> |  |

## Usage

To retrieve the values for metadata from matching pages and apply a chosen calculation

- Choose the **Metadata calculate** macro from the Confluence macro browser:

![image](media://bafe9e8e-2d72-46ee-af39-529f75bbd53f)

The macro requires the addition metadata value name for the calculation.

![image](media://9109ef65-4c2a-4293-9663-136448a4b894)

The default calculation is the sum of the values of the metadata value name.

![image](media://80e4be65-1a11-479f-91c8-f87cde34a899)

Using the macro editor, the content can be limited by the choice of

- Content labels
- Space key
- Content type

The root page for the macro is by default the current page.

The macro placeholder displays the added metadata value name.

For example, the following added **metadata-calculate** macro

![image](media://b2036d3f-60a2-4971-baaa-c42fc3299dc5)

This displays the numeric return for the chosen calculation for the selected metadata, **Installs**.

![image](media://26b3312b-b957-484e-b3ce-f25f846e7c7a)

### Example

Pages can be filtered by label so the named returned macro value is calculated using the named metadata values from the label filtered pages.

![image](media://97439995-f402-4a36-819e-60d1c2151cc4)

This is displayed on the page with the added macro the **Total (Sum)** for the metadata `MyValue` using the values of the `MyValue` metadata from each page with the `mylabel` label.

One of the macros using different filters can be added to the Confluence chart macro.

![image](media://d65eb32d-52cb-4abf-8ca7-95c0009e8c01)

This displays the retrieved metadata values:

![image](media://8276c851-a661-4b98-a28b-825fac267067)

## <span style="color: #091e42">Reference markup</span>

```plaintext
{metadata-calculate:Installs|key=CAI|root=InstallsSummary|label=jira_app|}
```

In the example, the calculate app would summarise the (default)sum of the metadata **Installs **values.

- The summed value returned is from the space with the key `CAI.`
- The `InstallsSummary` page is the root page for the report - the values being returned from child pages with the `jira_app` label.

## Related macros

- [https://appfire.atlassian.net/wiki/spaces/COMALACM/pages/655759844](https://appfire.atlassian.net/wiki/spaces/COMALACM/pages/655759844)
- [https://appfire.atlassian.net/wiki/spaces/COMALACM/pages/656580345](https://appfire.atlassian.net/wiki/spaces/COMALACM/pages/656580345)

## Related pages

- [Reporting and searching](https://appfire.atlassian.net/wiki/spaces/COMALACM/pages/656577723)