Skip to main content
Explore 38 recipes across data modeling, calculations, analytics patterns, pre-aggregations, configuration, APIs, and AI.

Data Modeling

Cube style guide

Best practices and conventions for structuring your Cube data models.

Designing metrics

Compare entity-first and metrics-first ways to structure views for BI tools, apps, and agents.

Entity-Attribute-Value model

Shape sparse EAV warehouse tables into queryable dimensions and joins.

Using Cube with dbt

Layer Cube on dbt-built warehouse models, aligning documentation patterns with your semantic layer.

Dynamic data models

Generate measures programmatically from changing reference data.

Dynamic union tables

Combine multiple database tables that relate to the same entity into a single cube.

Calculations & Metrics

Averages and percentiles

Model percentile-based metrics alongside averages for accurate representation of skewed distributions.

Nested aggregates

Express aggregates-of-aggregates like a median of per-group sums using joined cubes and subquery dimensions.

Filtered aggregates

Model cross-cube filters so measures aggregate facts while respecting dimensions from related cubes.

Period-over-period changes

Calculate week-over-week, month-over-month, and other period-over-period metric changes.

Dynamic parameters

Let users select filter values and use them in calculations without filtering the entire query.

Internal rate of return

Calculate XIRR for a schedule of cash flows that is not necessarily periodic.

Time Series & Calendars

String time dimensions

Work around non-timestamp time columns by casting strings to proper time dimension types.

Custom granularities

Implement custom time dimension granularities like fiscal quarters or custom week definitions.

Custom calendars

Map fact tables to retail or fiscal calendars using dedicated calendar cubes and proxy dimensions.

Data snapshots

Build point-in-time snapshots from change-history data to report status as of any date.

User & Event Analytics

Active users (DAU, WAU, MAU)

Measure customer engagement with daily, weekly, and monthly active user metrics.

Event analytics

Turn raw clickstream events into session definitions and metrics for product analytics.

Funnel analysis

Configure multi-step conversion funnels for product and marketing analytics.

Retention analysis & cohorts

Implement cohort-based retention analysis to track user engagement over time.

Pre-Aggregations

Non-additive measures

Accelerate averages, distinct counts, and similar non-additive measures with pre-aggregations.

Incremental builds

Rebuild only the time-bounded partitions you need instead of refreshing entire rollups.

Disabling pre-aggregations

Conditionally disable pre-aggregations based on environment or deployment context.

original_sql and rollups

Materialize expensive SQL once with original_sql, then reuse across rollup pre-aggregations.

Refreshing partitions

Partition-level refresh patterns for when dimension values change after initial load.

Multiple data sources

Join data from different warehouses with cross-database rollup joins.

Configuration

Environment variables

Reference deployment secrets and tunables from environment variables in your config.

SSL connections

Enable TLS to upstream databases with custom CA bundles and client certificates.

Optimizing data source usage

Reduce warehouse spend through pre-aggregation strategy and workload-aware settings.

Custom data source per tenant

Route each tenant to its own database while reusing a single data model.

Custom data model per tenant

Give each tenant a unique data model, from completely different to partially shared schemas.

APIs & Frontend

Unique values for a field

Power filter dropdowns by querying distinct dimension values from Cube’s data APIs.

Numeric values on the front-end

Coerce REST numeric strings into JavaScript numbers, with precision pitfalls and caveats.

Custom sorting

Sort query result sets by custom criteria beyond default ordering.

Pagination

Implement paged tables over Cube queries using limit, offset, and deterministic ordering.

Drilldowns

Configure drill members and fetch detail rows behind an aggregate value.

Real-time data fetch

Build live-updating dashboards using WebSocket transport and client subscriptions.

AI

Agent-to-agent with Chat API

Wrap the Cube Chat API as a LangChain tool so an orchestrating agent can query data on demand.