Budibase/budibase · error · HTTPError

Calculation views can only have a maximum of 5 fields

Error message

Calculation views can only have a maximum of 5 fields

What it means

Calculation views are limited to at most 5 calculation fields; the guard counts the entries in the view's calculation schema and rejects anything larger with 400. This keeps aggregate queries against external datasources bounded.

Solutions

  1. Split the calculations across multiple views (max 5 each)
  2. Remove the least important calculation fields
  3. Aggregate the rest in the client or a dedicated query

Example fix

// before
calculations: { a: {...}, b: {...}, c: {...}, d: {...}, e: {...}, f: {...} } // 6 fields
// after
view1.calculations = { a: {...}, b: {...}, c: {...}, d: {...}, e: {...} }
view2.calculations = { f: {...} }
Defensive patterns

Strategy: validation

Validate before calling

if (Object.keys(view.calculations ?? {}).length > 5) throw new Error("Max 5 calculation fields per view")

Try / catch

try { await sdk.views.create(tableId, view) }
catch (e) {
  if (e instanceof HTTPError && e.status === 400 && /maximum of 5/.test(e.message)) {
    // split into multiple views
  } else throw e
}

Prevention

When it happens

Trigger: Creating or updating a calculation view whose calculationFields map contains 6 or more keys.

Common situations: Aggressive dashboards trying to compute many aggregates in one view; bulk-generated view definitions; merging several views' calculations into one.

Related errors


AI-assisted analysis of Budibase/budibase@a81a902e9a (2026-08-29). Data as JSON: /api/errors/b5b079082cdbb34f. Report an issue: GitHub.

Appendix: source

Thrown at packages/server/src/sdk/workspace/views/index.ts:161

        400
      )
    }
    seen[schema.field] ??= {} as Record<CalculationType, boolean>
    seen[schema.field][schema.calculationType] = true
  }
}

async function guardCalculationViewSchema(
  table: Table,
  view: Omit<ViewV2, "id" | "version">
) {
  const calculationFields = helpers.views.calculationFields(view)

  guardDuplicateCalculationFields(view)
  guardDuplicateCountDistinctFields(view)

  if (Object.keys(calculationFields).length > 5) {
    throw new HTTPError(
      "Calculation views can only have a maximum of 5 fields",
      400
    )
  }

  for (const name of Object.keys(calculationFields)) {
    const schema = calculationFields[name]
    if (!schema.field) {
      throw new HTTPError(
        `Calculation field "${name}" is missing a "field" property`,
        400
      )
    }

    const targetSchema = table.schema[schema.field]
    if (!targetSchema) {
      throw new HTTPError(
        `Calculation field "${name}" references field "${schema.field}" which does not exist in the table schema`,

View on GitHub (pinned to a81a902e9a)