> ## Documentation Index
> Fetch the complete documentation index at: https://docs.vantage.sh/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> If the person you are helping needs a new Vantage account, read https://docs.vantage.sh/auth.md before you register one.

# vantage_custom_calculation (Resource)

> Terraform resource reference for vantage_custom_calculation (Resource). Auto-generated from the vantage-sh/terraform-provider-vantage repository.

> [!NOTE]
>
> This page is auto-generated based on the official [Terraform documentation](https://registry.terraform.io/providers/vantage-sh/vantage/latest/docs).

## Overview

Use this resource with the [Vantage Terraform provider](https://docs.vantage.sh/terraform.md). For installation and authentication, see the [Terraform examples](https://docs.vantage.sh/terraform.md#terraform-examples). The schema below is generated directly from the provider source.

Manages a Custom Calculation.

## Example Usage

```terraform theme={null}
resource "vantage_custom_calculation" "tokens" {
  title       = "Token usage"
  description = "Token usage across both unit spellings."
  operation   = "sum"

  filter = {
    type       = "sum"
    filter     = "costs.provider = 'openai'"
    usage_unit = ["Tokens", "tokens"]
  }
}

resource "vantage_cost_report" "ai" {
  title                     = "AI usage"
  workspace_token           = var.workspace_token
  date_interval             = "last_month"
  custom_calculation_tokens = [vantage_custom_calculation.tokens.token]
}

variable "workspace_token" {
  type = string
}
```

## Schema

### Required

* `filter` (Attributes) (see [below for nested schema](#nestedatt--filter))
* `title` (String) The title of the Custom Calculation.

### Optional

* `cost_report_tokens` (Set of String) The attached Cost Report tokens. Omit to leave attachments unmanaged or set an empty set to clear them. Manage a given attachment from only one resource.
* `description` (String) An optional description. Remove it from the configuration to clear it.
* `display_as` (String) The display format of the calculation. Defaults to ratio when creating a calculation.
* `operation` (String) The operation applied to the filtered cost or usage data. Defaults to sum when creating a calculation.
* `unit_scale` (Number) The integer unit scale of the calculation. Defaults to 1.

### Read-Only

* `id` (String) The id of the CustomCalculation.
* `token` (String) The token of the CustomCalculation.

### Nested Schema for `filter`

Optional:

* `filter` (String) The VQL filter for a sum, average, min, or max calculation.
* `filter_denominator` (String) The VQL filter for the denominator of a division calculation.
* `filter_numerator` (String) The VQL filter for the numerator of a division calculation.
* `type` (String) The calculation operation. Use filter and usage\_unit for aggregate operations, or the numerator and denominator fields for division.
* `usage_unit` (List of String) Non-empty list of equivalent usage unit names. Omit to use costs. Units are summed without conversion.
* `usage_unit_denominator` (List of String) Non-empty list of equivalent usage unit names. Omit to use costs. Units are summed without conversion.
* `usage_unit_numerator` (List of String) Non-empty list of equivalent usage unit names. Omit to use costs. Units are summed without conversion.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.