
Loading...
The semantic layer is your single source of truth for business metrics and dimensions, ensuring consistent calculations across all your analytics. No more 'which revenue number is correct?' conversations.
A semantic layer sits between your raw data models and your BI tools, providing a consistent, governed interface for analytics.
Define revenue once, use everywhere
Map technical columns to business names
Control who can query what
Let analysts explore without SQL
DataChonk generates semantic layer definitions compatible with dbt's MetricFlow, the industry-standard semantic layer for dbt projects.
semantic_models:
- name: orders
model: ref('fct_orders')
entities:
- name: order_id
type: primary
- name: customer_id
type: foreign
dimensions:
- name: order_date
type: time
type_params:
time_granularity: day
- name: status
type: categorical
measures:
- name: order_total
agg: sum
expr: amount
- name: order_count
agg: count
expr: order_idmetrics:
- name: revenue
label: Total Revenue
description: Sum of all order amounts
type: simple
type_params:
measure: order_total
- name: average_order_value
label: AOV
description: Average revenue per order
type: derived
type_params:
expr: revenue / order_count
metrics:
- revenue
- order_count# Generate semantic layer from existing models
datachonk semantic generate --model fct_orders
# Validate semantic definitions
datachonk semantic validate
# Preview metric queries
datachonk semantic query --metric revenue --group-by order_dateOnce your semantic layer is defined, it integrates with popular BI platforms.
| Property | Type | Default | Description |
|---|---|---|---|
| Tableau | - | - | dbt Semantic Layer connector |
| Looker | - | - | LookML generation from metrics |
| Power BI | - | - | DirectQuery with semantic layer API |
| Hex | - | - | Native dbt Semantic Layer support |
| Mode | - | - | dbt Cloud integration |
Use MetricFlow to query your semantic layer directly.
# Query metrics with dimensions
mf query --metrics revenue,order_count \
--group-by metric_time__month,customer__region \
--where "metric_time__month >= '2024-01-01'"
# Results
┏━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━┳━━━━━━━━━━━━━┓
┃ metric_time__month ┃ customer__region┃ revenue ┃ order_count ┃
┡━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━╇━━━━━━━━━━━━━┩
│ 2024-01 │ North America │ 1,245,000 │ 4,521 │
│ 2024-01 │ Europe │ 892,000 │ 3,102 │
│ 2024-02 │ North America │ 1,389,000 │ 4,892 │
└─────────────────────┴─────────────────┴───────────┴─────────────┘| Property | Type | Default | Description |
|---|---|---|---|
| dbt 1.9+ | - | - | Full MetricFlow integration |
| dbt 1.8.x | - | - | Semantic models (beta) |
| dbt 1.7.x | - | - | Legacy metrics (deprecated) |
Upgrade Recommended