You've already done the hard work of defining clean business logic in Databricks—now you want to visualize those metrics in a Tableau dashboard without duplicating formulas or risking inconsistent aggregations. Databricks Metric Views keep semantic definitions centralized in one place, and pairing them with MEASURE() in Custom SQL lets Tableau access those pre-defined metrics directly rather than rebuilding logic from scratch.

For the walkthrough below, I use a mock coffee e-commerce dataset under the workspace.coffeebean schema (with orders, customers, and products tables). All of that feeds into the workspace.coffeebean.coffeebean_metric_view, which combines order records with customer and product details and makes standardized metrics available—including gross and net revenue, COGS, gross margin percentage, average order value, refund and cancellation rates, and trailing 30-day net revenue.

Using Custom SQL and the MEASURE() function rather than plain aggregations allows business rules to stay enforced automatically once the data is in Tableau. So, for example, gross_revenue will still exclude cancelled orders, and net_revenue and cogs will maintain their exclusion of both cancelled and refunded orders.

Install the Databricks driver

Start off by obtaining the necessary driver. This is essentially the bridge that will connect Databricks and Tableau, allowing the Metric View to live in both.

Once it's downloaded, click on the compressed file and begin the installation process:

After agreeing to the conditions and confirming the installation location, you will need to allow it to make changes to your device.

Connect to Databricks in Tableau

Now that the driver is ready to go, open Tableau and within the Connect panel, under To A Server, search for Databricks. You may have to click 'More...' to see it as an option.

Having selected Databricks, you will see a window like the one below pop up. I've found that the easiest way to get the credentials you need is to go back to Databricks and ask Genie what your Server Hostname and HTTP Path are for connecting to Tableau. Setting the Authentication method to Databricks login will open a browser tab once you click Sign In.

After logging into Databricks, you will see this verification window.

Set Up Custom SQL

Return to Tableau and within the Data Source tab, input the name of the Catalog and Database where your Metric View lives in Databricks. Then instead of selecting a Table, click on New Custom SQL. (You do not want to input it as a regular table because Tableau will then treat its measures like ordinary columns and generate standard SQL aggregations (such as SUM()) instead of evaluating the metric view's definitions).

Now input a select query where every measure in your Metric View is wrapped in MEASURE(). The measure function allows Tableau to access the measures in the Metric View.

A GROUP BY clause is needed whenever dimensions are included in the Custom SQL query, and those GROUP BY columns should match the level of detail your Tableau visualization needs (since Tableau won't re-evaluate MEASURE() dynamically across different levels of granularity). Be careful to avoid misleading or unintentional aggregations.

Here's my example Custom SQL:

SQL
SELECT tier,
       roast_name,
       MEASURE(gross_revenue) AS gross_revenue,
       MEASURE(net_revenue)   AS net_revenue,
       MEASURE(gross_profit)  AS gross_profit
FROM workspace.coffeebean.coffeebean_metric_view
GROUP BY tier, roast_name

Go ahead and click OK and you'll see your Custom Query appear in the place of traditional tables, and its contents show below, just as those of a table would.

All set! With your Custom SQL query in place, you can switch over to a worksheet and start building your dashboard with full confidence that your metric definitions stay consistent.