> For the complete documentation index, see [llms.txt](https://docs.infotopics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infotopics.com/drilldowntree/configuration/customize-measures/custom-calculations.md).

# Custom calculations

DrillDownTree lets you add your own calculations as measures, such as a profit ratio. Custom calculations are computed on the aggregated values of each node, so a ratio like `SUM(Profit) / SUM(Sales)` gives the correct ratio at every level of your tree.

<figure><img src="https://3696064508-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Ffen81laUQFBf286HYARr%2Fuploads%2Fgit-blob-1c1828e2de3aa9ff7fc91ebee84a33837ce760b1%2FDDT_CustomizeMeasures_Calculation.png?alt=media" alt="A Profit ratio calculation in the Alias &#x26; Calculation section" width="498"><figcaption></figcaption></figure>

## Add a custom calculation

1. In [Customize measures](https://docs.infotopics.com/drilldowntree/configuration/customize-measures.md), click **+** below **Measures**. A new measure called "Calculation" followed by a number is added at the top of the list.
2. Open **Alias & Calculation** and enter a name for your calculation in **Alias**.
3. Write your calculation in the **Custom calculation** box:
   * Type `@` and pick a measure from your data. DrillDownTree inserts its name, for example `SUM(Profit)`.
   * Type `#` or use the operator buttons to add `+`, `-`, `*`, `/` and parentheses. Select part of your calculation and click **()** to put it between parentheses.
   * You can use numbers too, for example `SUM(Profit) / SUM(Sales) * 100`.
4. Click **Save**.

Your calculation now appears in the measure switcher, and you can format it like any other measure.

{% hint style="info" %}
A custom calculation can only use measures from your data, not other custom calculations. When DrillDownTree doesn't understand a calculation, it shows "Invalid Calculation" and doesn't save it.
{% endhint %}

## Rename a measure

You can use **Alias** for measures from your data too. Select the measure, enter a new name in **Alias** and click **Save**. The alias is shown in the measure switcher, the tooltip and the legend.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.infotopics.com/drilldowntree/configuration/customize-measures/custom-calculations.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
