Databricks AI/BI Calculated Fields Databricks SQL

Tableau Calculated Fields to Databricks SQL: Function Mapping and Conversion Reference

September 8, 2026

A Tableau calculated field lands in one of three places in Databricks AI/BI: a column in the dataset SQL, a calculated dimension or measure on the dataset, or a measure in a Unity Catalog metric view. Which one you pick follows from whether the field is row-level, aggregate, or shared across dashboards.

The function names are the easy half. The argument orders and null rules below are what let a converted formula run cleanly and still return a different number.

Where a calculated field lands in Databricks AI/BI

Tableau keeps every calculation inside the workbook. Databricks AI/BI spreads them across three layers, and the layer you choose decides who else can reuse the logic and when it runs. The third of them, a metric view, is a measure definition stored in Unity Catalog rather than inside a dashboard.

Tableau calculated fieldWhere it goes in Databricks AI/BIWhy
Row-level, used as a dimension, filter, or groupingA column in the dataset SQLThe value belongs to the data, and other datasets can select it
Row-level, needed by one dashboard onlyCalculated dimensionAdded on the dataset without editing the query
Aggregate, such as SUM, AVG, COUNTDCalculated measureRe-aggregates automatically against whatever the chart groups by
Aggregate reused across dashboards and notebooksMeasure in a Unity Catalog metric viewDefined once, resolved at query time by every consumer
LOD expressionWindow form of a custom calculation, or dataset SQLLOD expressions
Table calculationAGGREGATE OVER measure, or a SQL window functionTable calculations

Custom calculations are scoped to the dataset and dashboard where they are defined, up to 200 per dataset, and results of 100,000 rows and 100MB or less compute in the browser rather than on the SQL warehouse (as of September 2026). Table visualizations accept calculated dimensions but not calculated measures, which bites in a rebuilt Tableau crosstab. Dataset queries are read-only, so logic needing a temporary table belongs upstream.

How the functions map

Signatures below come from the Databricks SQL language manual and Tableau's function reference. Read the notes before any find and replace: DATEDIFF reverses its dates in one of its two Databricks forms and keeps them in the other.

TableauDatabricks SQLNote
IF ... THEN ... ELSEIF ... ELSE ... ENDCASE WHEN ... THEN ... ELSE ... ENDTableau's CASE [x] WHEN maps to CASE expr WHEN
IIF(test, then, else, [unknown])iff(cond, expr1, expr2)Three arguments only; Tableau's optional unknown value needs its own branch
ZN([x])zeroifnull(x)A documented synonym for coalesce(x, 0); prefer coalesce, since the zeroifnull page is labeled for Databricks Runtime 16.0 and above
IFNULL(a, b) / ISNULL([x])ifnull(a, b), nvl(a, b) or coalesce(a, b) / isnull(x)Same argument order in all three; isnull returns a boolean
DATEDIFF('day', [start], [end])datediff(end, start)Argument order reverses, and this form counts whole days only
DATEDIFF('month', [start], [end])datediff(MONTH, start, end)Keeps Tableau's order and takes an unquoted keyword; Databricks counts whole elapsed units, so check month and year differences against the workbook
DATETRUNC('month', [d]) / DATEPART('year', [d])date_trunc('MONTH', d) / date_part('YEAR', d)Unit is a quoted string literal; date_trunc returns a TIMESTAMP
DATEADD('month', 3, [d])dateadd(MONTH, 3, d)Same order, unquoted unit, timestamp input
CONTAINS / STARTSWITH / ENDSWITHcontains(expr, subExpr), startswith, endswithSame order; matching is case-sensitive, so endswith('SparkSQL', 'sql') is false
SPLIT(string, delimiter, token)split_part(str, delim, partNum)A negative part number counts from the right in both
REGEXP_EXTRACT(string, pattern)regexp_extract(str, regexp [, idx])idx defaults to 1, the first capture group
INT / FLOAT / STR / DATEcast(x AS BIGINT / DOUBLE / STRING / DATE)try_cast returns NULL instead of failing on bad input
COUNTD([x])count(DISTINCT x)approx_count_distinct(x) trades exactness for speed
ATTR([x])No direct equivalentTableau returns an asterisk when values differ; in SQL pick min(x) or any_value(x)
SUM([a]) / SUM([b])try_divide(SUM(a), SUM(b))Plain division by zero raises DIVIDE_BY_ZERO

What changes about nulls, dates and types

A formula that compiles is not a formula that agrees with the old dashboard. These differences surface in a total rather than in an error message.

DifferenceWhat Databricks SQL doesWhat to write instead
Nulls in comparisonsx <> 'A' is null when x is null, so the row fails the test, as in Tableau, but easy to lose when a workbook relied on a [Field] != 'A' quick filterHandle nulls on purpose with isnull(x) or coalesce(x, 'Unknown')
Division by zeroRaises DIVIDE_BY_ZERO, SQLSTATE 22012, rather than returning a nulltry_divide(a, b), which returns NULL for a zero divisor
Start of weekWeeks start Monday: date_trunc('WEEK', d) truncates to MondayCheck any Tableau formula that passed a start_of_week argument
Date part namesQuoted string for date_trunc and date_part, unquoted keyword for dateadd and unit-form datediffCopy the unit list from each function page

When to promote a calculation to a metric view

A Unity Catalog metric view separates measure definitions from the fields used to group, filter and aggregate them, so a metric is defined once and resolved at query time by notebooks, dashboards, Genie Agents and alerts. A formula that exists to make one chart work is a calculated measure; a formula three teams argue about is a metric view.

In a migration the useful test is duplication. When one revenue definition turns up in eleven workbooks with four slightly different filters, converting each copy faithfully rebuilds the disagreement inside a new tool. Promote the shared definitions first and leave one-off calculations local. Nobody wrote those eleven copies carelessly: a deadline is always closer than a modeling meeting.

What Antares does with calculated fields

Reading a workbook's calculated fields by hand is the part of scoping nobody wants to do twice. The free Analyzer does that pass deterministically, on metadata alone, without touching the source environment, and returns an inventory of the estate. The Converter is deterministic-first with guardrailed, validated AI steps, and any construct it cannot verify is flagged instead of guessed at.

That division is the whole job of a BI migration tool: the mapping is mechanical, and the judgment calls, including which definitions deserve a metric view, stay yours. Tableau to Databricks AI/BI is a shipped route, at a flat $200 per source dashboard with LLM costs on top, typically under $20. Try a sample conversion before you scope your own workbooks.

Next in this cluster: LOD expressions in Databricks SQL for the pinned aggregates, table calculations in Databricks AI/BI for the window functions, and the migration guide for the order of the work. The Power BI twin of this page is Tableau calculated fields to DAX. Sources: the Databricks custom calculation function reference, Tableau's type conversion functions and its guide to aggregate calculations.

← Back to the Tableau to Databricks Migration guide

Related Migration Resources

Frequently asked questions

Where do Tableau calculated fields go in Databricks AI/BI?

Into one of three homes. Row-level fields used as dimensions belong in the dataset SQL or as a calculated dimension. Aggregate fields become calculated measures on the dataset. Definitions shared across dashboards, notebooks and Genie Agents belong in a Unity Catalog metric view, where they are resolved at query time.

Does Databricks SQL DATEDIFF work like Tableau DATEDIFF?

Not in its two-argument form. Tableau writes DATEDIFF('day', start, end); the Databricks two-argument datediff(end, start) reverses those dates and counts whole days only. The unit form, datediff(unit, start, end), keeps Tableau's order and takes an unquoted keyword such as MONTH or QUARTER.

What replaces ZN and IFNULL in Databricks SQL?

ZN(x) becomes zeroifnull(x), which Databricks documents as a synonym for coalesce(x, 0); coalesce is the portable form, since the zeroifnull page is labeled for Databricks Runtime 16.0 and above. IFNULL(a, b) becomes ifnull(a, b), nvl(a, b) or coalesce(a, b), all with the same argument order. For ratios, try_divide returns NULL rather than raising DIVIDE_BY_ZERO.

Should a converted calculation be a custom calculation or a metric view?

Custom calculations are scoped to one dataset on one dashboard, capped at 200 per dataset as of September 2026. That fits a formula serving a single chart. A definition several dashboards depend on belongs in a Unity Catalog metric view, so Genie Agents and notebooks answer from the same numbers.

Let's talk migration.

Get your free Migration Readiness Score, or talk to our team about end-to-end delivery.