Tableau→Snowflake metric build: extract calc-fields FIRST, mirror verbatim
Tableau ↔ Snowflake metric formula reconciliation: extract Tableau calc-fields BEFORE writing the Snowflake metric
Discovered: 2026-05-08, Sales+CRM Cortex Analyst alignment session — found via parallel Cortex audit that AJ ran independently.
Pattern: Building a Snowflake Cortex Analyst metric BEFORE extracting the canonical Tableau calc-field formula leads to silent formula divergence. The error is undetectable until someone runs both side-by-side because:
- Snowflake metric returns a number that looks plausible
- Tableau dashboard returns a different plausible number
- Tool descriptions, field names, and metric names all agree
- Only the FILTER CLAUSES differ — and those are accounting-grade business decisions, not infrastructure quirks
Concrete case: My VW_SALES_OVERVIEW_NEW.GROSS_SALES_CR metric used 5 stages — STAGE_NAME IN ('Unit Booked','Cancelled','Cancellation Initiated','Negotiation','Unit Blocked'). Tableau’s actual Gross Sales calc-field uses 3 — IF [Stage Name] IN ("Unit Booked","Cancelled","Cancellation Initiated"). Two extra stages inflated the metric by ~₹22 Cr (Negotiation ₹13.48 Cr + Unit Blocked ₹9.02 Cr). Both small absolutely; conceptually wrong (a booking still in ‘Negotiation’ is NOT a gross sale).
Mandatory workflow for building Snowflake metrics from existing Tableau dashboards:
- Phase 1: extract calc-fields via
mcp__tableau-mcp__metadata_get_calculated_fields(content_type='workbook', content_id=<luid>) - Phase 2: copy the IF/AND clauses VERBATIM into the Snowflake metric expression
- Phase 3: byte-level diff (or visual side-by-side) against the extracted formula before any
CREATE OR REPLACE - Never infer “what stages should reasonably be included” — accounting-grade business decisions are baked into the original Tableau formula
Companion finding: Even with formula identity, expect a small (1-5%) variance between Tableau dashboard headline and Snowflake metric. That variance is workbook-level CONTEXT FILTERS not visible in calc-field metadata API — only in worksheet-level filter cards or workbook XML. To eliminate the residual variance, inspect .twbx XML via tableau-twbx skill.
Reach: any future Cortex Analyst-built-from-Tableau workflow. Tier-1 process change for snowflake-report-mart skill (Phase 1 should now mandate calc-field extraction).