---
title: "Calculate total from query"
method: POST
path: "/api/v1/projects/{projectUuid}/calculate-total"
tags: ["Projects"]
deprecated: true
---

# Calculate total from query

`POST /api/v1/projects/{projectUuid}/calculate-total`

> **Deprecated.**

Calculate all metric totals from a metricQuery

## Path parameters

- `projectUuid` string, required

## Request body

- CalculateTotalFromQuery
  - `invalidateCache` boolean
  - `parameters` ParametersValuesMap — Construct a type with a set of properties K of type T
  - `explore` string, required
  - `metricQuery` MetricQueryRequest, required
    - `dimensionOverrides` DimensionOverrides
    - `metricOverrides` MetricOverrides
    - `pivotDimensions` FieldId[]
    - `timezone` string
    - `metadata` object
      - `hasADateDimension` PickCompiledDimensionLabelOrNameOrTable, required — From T, pick a set of properties whose keys are in the union K
        - `name` string, required
        - `label` string, required
        - `table` string, required
    - `dateZoom` DateZoom
      - `xAxisFieldId` string
      - `granularity` union
        - 'Second' | 'Minute' | 'Hour' | 'Day' | 'Week' | 'Month' | 'Quarter' | 'Year'
        - string
    - `customDimensions` CustomDimension[]
      - union
        - union
          - FixedNumberBinDimension
            - `id` string, required — Unique identifier for the custom dimension
            - `name` string, required — Display name for the custom dimension
            - `table` string, required — Table this custom dimension belongs to
            - `type` 'bin', required
            - `dimensionId` string, required
            - `binType` 'fixed_number', required
            - `binNumber` number, double, required
          - FixedWidthBinDimension
            - `id` string, required — Unique identifier for the custom dimension
            - `name` string, required — Display name for the custom dimension
            - `table` string, required — Table this custom dimension belongs to
            - `type` 'bin', required
            - `dimensionId` string, required
            - `binType` 'fixed_width', required
            - `binWidth` number, double, required
          - CustomRangeBinDimension
            - `id` string, required — Unique identifier for the custom dimension
            - `name` string, required — Display name for the custom dimension
            - `table` string, required — Table this custom dimension belongs to
            - `type` 'bin', required
            - `dimensionId` string, required
            - `binType` 'custom_range', required
            - `customRange` BinRange[], required
              - …
          - CustomGroupBinDimension
            - `id` string, required — Unique identifier for the custom dimension
            - `name` string, required — Display name for the custom dimension
            - `table` string, required — Table this custom dimension belongs to
            - `type` 'bin', required
            - `dimensionId` string, required
            - `binType` 'custom_group', required
            - `customGroups` BinGroup[], required
              - …
        - CustomSqlDimension
          - `id` string, required — Unique identifier for the custom dimension
          - `name` string, required — Display name for the custom dimension
          - `table` string, required — Table this custom dimension belongs to
          - `type` 'sql', required
          - `sql` string, required — SQL expression for the custom dimension
          - `dimensionType` 'string' | 'number' | 'timestamp' | 'date' | 'boolean', required
    - `csvLimit` number, double
    - `additionalMetrics` AdditionalMetric[]
      - `label` string — Display label for the metric
      - `type` 'percentile' | 'average' | 'count' | 'count_distinct' | 'sum' | 'sum_distinct' | 'average_distinct' | 'min' | 'max' | 'percent_of_previous' | 'percent_of_total' | 'running_total' | 'number' | 'median' | 'string' | 'date' | 'timestamp' | 'boolean', required
      - `description` string — Description of what the metric measures
      - `sql` string, required — SQL expression (e.g., ${TABLE}.column_name)
      - `hidden` boolean — Whether the metric is hidden from users
      - `round` number, double — Number of decimal places
      - `compact` union
        - 'auto' | 'thousands' | 'millions' | 'billions' | 'trillions' | 'kilobytes' | 'megabytes' | 'gigabytes' | 'terabytes' | 'petabytes' | 'kibibytes' | 'mebibytes' | 'gibibytes' | 'tebibytes' | 'pebibytes'
        - 'K' | 'thousand' | 'M' | 'million' | 'B' | 'billion' | 'T' | 'trillion' | 'KB' | 'kilobyte' | 'MB' | 'megabyte' | 'GB' | 'gigabyte' | 'TB' | 'terabyte' | 'PB' | 'petabyte' | 'KiB' | 'kibibyte' | 'MiB' | 'mebibyte' | 'GiB' | 'gibibyte' | 'TiB' | 'tebibyte' | 'PiB' | 'pebibyte'
      - `format` union — Format string (legacy format specification)
        - 'km' | 'mi' | 'si' | 'usd' | 'gbp' | 'eur' | 'jpy' | 'dkk' | 'id' | 'percent'
        - string
      - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
      - `table` string, required — Table name the metric belongs to
      - `name` string, required — Internal name of the metric
      - `index` number, double — Display order index
      - `filters` MetricFilterRule[] — Filters to apply to this metric
        - `includeNull` boolean — For the `equals` operator on string fields, also match rows where the field is null (compiles to `field IN (...) OR field IS NULL`). Lets users combine null with selected values in a single "is" rule.
        - `values` AnyType[] — Values to filter by
          - unknown
        - `operator` 'isNull' | 'notNull' | 'equals' | 'notEquals' | 'startsWith' | 'endsWith' | 'include' | 'doesNotInclude' | 'lessThan' | 'lessThanOrEqual' | 'greaterThan' | 'greaterThanOrEqual' | 'inThePast' | 'notInThePast' | 'inTheNext' | 'inTheCurrent' | 'notInTheCurrent' | 'inBetween' | 'notInBetween' | 'inPeriodToDate', required
        - `id` string, required — Unique identifier for the filter
        - `target` object, required — Target field for the filter
          - `fieldRef` string, required — Field reference to filter on (e.g., 'table_name.field_name')
        - `settings` unknown
        - `disabled` boolean — Whether this filter is disabled
        - `required` boolean — Whether this filter is required
        - `caseSensitive` boolean — Overrides the field/explore case-sensitivity for this rule only. Used by internal features like autocomplete search that must always match case-insensitively regardless of the field's configured setting.
      - `baseDimensionName` string — Name of the base dimension/column this metric aggregates
      - `baseMetricName` string — Name of the explore metric this metric was cloned from
      - `uuid` string, nullable — Unique identifier for the metric
      - `percentile` number, double — Percentile value for percentile metrics
      - `distinctKeys` string[]
      - `formatOptions` CustomFormat
        - `type` 'default' | 'percent' | 'currency' | 'number' | 'id' | 'date' | 'timestamp' | 'bytes_si' | 'bytes_iec' | 'custom', required
        - `round` number, double — Number of decimal places
        - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
        - `currency` string — Currency code (e.g., USD, GBP, EUR)
        - `compact` union
          - 'auto' | 'thousands' | 'millions' | 'billions' | 'trillions' | 'kilobytes' | 'megabytes' | 'gigabytes' | 'terabytes' | 'petabytes' | 'kibibytes' | 'mebibytes' | 'gibibytes' | 'tebibytes' | 'pebibytes'
          - 'K' | 'thousand' | 'M' | 'million' | 'B' | 'billion' | 'T' | 'trillion' | 'KB' | 'kilobyte' | 'MB' | 'megabyte' | 'GB' | 'gigabyte' | 'TB' | 'terabyte' | 'PB' | 'petabyte' | 'KiB' | 'kibibyte' | 'MiB' | 'mebibyte' | 'GiB' | 'gibibyte' | 'TiB' | 'tebibyte' | 'PiB' | 'pebibyte'
        - `prefix` string — Prefix to prepend to formatted values
        - `suffix` string — Suffix to append to formatted values
        - `timeInterval` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
        - `custom` string — Custom format string
      - `generationType` 'periodOverPeriod' — Optional marker for metrics generated by the system. Currently used for Period-over-Period (PoP) previous-period metrics.
      - `baseMetricId` string
      - `timeDimensionId` string
      - `granularity` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
      - `periodOffset` number, double — For PoP-generated metrics, the number of periods to offset by (>= 1).
    - `tableCalculations` TableCalculation[], required
      - union
        - SqlTableCalculation
          - `totalMode` 'formula' | 'sum_of_rows' | 'none'
          - `type` 'number' | 'string' | 'date' | 'timestamp' | 'boolean'
          - `format` CustomFormat
            - `type` 'default' | 'percent' | 'currency' | 'number' | 'id' | 'date' | 'timestamp' | 'bytes_si' | 'bytes_iec' | 'custom', required
            - `round` number, double — Number of decimal places
            - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
            - `currency` string — Currency code (e.g., USD, GBP, EUR)
            - `compact` union
              - …
            - `prefix` string — Prefix to prepend to formatted values
            - `suffix` string — Suffix to append to formatted values
            - `timeInterval` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
            - `custom` string — Custom format string
          - `displayName` string, required — Display name shown in the UI
          - `name` string, required — Internal name of the table calculation
          - `index` number, double — Display order index
          - `sql` string, required — SQL expression for the calculation (can reference fields with ${table.field})
        - TemplateTableCalculation
          - `totalMode` 'formula' | 'sum_of_rows' | 'none'
          - `type` 'number' | 'string' | 'date' | 'timestamp' | 'boolean'
          - `format` CustomFormat
            - `type` 'default' | 'percent' | 'currency' | 'number' | 'id' | 'date' | 'timestamp' | 'bytes_si' | 'bytes_iec' | 'custom', required
            - `round` number, double — Number of decimal places
            - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
            - `currency` string — Currency code (e.g., USD, GBP, EUR)
            - `compact` union
              - …
            - `prefix` string — Prefix to prepend to formatted values
            - `suffix` string — Suffix to append to formatted values
            - `timeInterval` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
            - `custom` string — Custom format string
          - `displayName` string, required — Display name shown in the UI
          - `name` string, required — Internal name of the table calculation
          - `index` number, double — Display order index
          - `template` union, required
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
            - object
              - …
        - FormulaTableCalculation
          - `totalMode` 'formula' | 'sum_of_rows' | 'none'
          - `type` 'number' | 'string' | 'date' | 'timestamp' | 'boolean'
          - `format` CustomFormat
            - `type` 'default' | 'percent' | 'currency' | 'number' | 'id' | 'date' | 'timestamp' | 'bytes_si' | 'bytes_iec' | 'custom', required
            - `round` number, double — Number of decimal places
            - `separator` 'default' | 'commaPeriod' | 'spacePeriod' | 'periodComma' | 'noSeparatorPeriod' | 'apostrophePeriod'
            - `currency` string — Currency code (e.g., USD, GBP, EUR)
            - `compact` union
              - …
            - `prefix` string — Prefix to prepend to formatted values
            - `suffix` string — Suffix to append to formatted values
            - `timeInterval` 'RAW' | 'YEAR' | 'QUARTER' | 'MONTH' | 'WEEK' | 'DAY' | 'HOUR' | 'MINUTE' | 'SECOND' | 'MILLISECOND' | 'DAY_OF_WEEK_INDEX' | 'DAY_OF_MONTH_NUM' | 'DAY_OF_YEAR_NUM' | 'WEEK_NUM' | 'MONTH_NUM' | 'QUARTER_NUM' | 'YEAR_NUM' | 'DAY_OF_WEEK_NAME' | 'MONTH_NAME' | 'QUARTER_NAME' | 'HOUR_OF_DAY_NUM' | 'MINUTE_OF_HOUR_NUM'
            - `custom` string — Custom format string
          - `displayName` string, required — Display name shown in the UI
          - `name` string, required — Internal name of the table calculation
          - `index` number, double — Display order index
          - `formula` string, required — Spreadsheet-like formula compiled to SQL at query time
    - `limit` number, double, required
    - `sorts` SortField[], required
      - `pivotValues` PivotSortAnchor[] — Pins the row-sort anchor to a specific pivot column. Ignored for non-pivoted results.
        - `value` union, required
          - string
          - number, double
          - boolean
        - `reference` string, required
      - `nullsFirst` boolean — Sort null values first
      - `descending` boolean, required — Sort in descending order
      - `fieldId` string, required — Field ID to sort by
    - `filters` object, required
      - `tableCalculations` unknown
      - `metrics` unknown
      - `dimensions` unknown
    - `metrics` FieldId[], required
    - `dimensions` FieldId[], required
    - `exploreName` string, required

## Response `200`

Success

- ApiCalculateTotalResponse
  - `results` RecordStringNumber, required — Construct a type with a set of properties K of type T
  - `status` 'ok', required

## Other responses

- `default` — Error

---

[API](https://skmtc.net/lightdash/apis/lightdash-api.md) · [All operations](https://skmtc.net/lightdash/apis/lightdash-api/llms.txt) · [OpenAPI document](https://skmtc-service-staging.skmtc.workers.dev/v1/apis/lightdash/lightdash-api/versions/40c933755c9a/schema)
