> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cube.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Step-by-step tutorials and best practices for getting the most out of Cube.

Explore **41 recipes** across data modeling, calculations, analytics patterns,
pre-aggregations, configuration, APIs, and AI.

## Data Modeling

> [card] [Cube style guide](https://docs.cube.dev/recipes/data-modeling/style-guide.md)
>
> Best practices and conventions for structuring your Cube data models.

> [card] [Designing metrics](https://docs.cube.dev/recipes/data-modeling/designing-metrics.md)
>
> Compare entity-first and metrics-first ways to structure views for BI tools, apps, and agents.

> [card] [Entity-Attribute-Value model](https://docs.cube.dev/recipes/data-modeling/entity-attribute-value.md)
>
> Shape sparse EAV warehouse tables into queryable dimensions and joins.

> [card] [Using Cube with dbt](https://docs.cube.dev/recipes/data-modeling/dbt.md)
>
> Layer Cube on dbt-built warehouse models, aligning documentation patterns with your semantic layer.

> [card] [dbt pull with the Cube CLI](https://docs.cube.dev/recipes/data-modeling/dbt-cli.md)
>
> Pull several dbt projects into one deployment, commit generated cubes through your own pull requests, and promote syncs from CI.

> [card] [Dynamic data models](https://docs.cube.dev/recipes/data-modeling/using-dynamic-measures.md)
>
> Generate measures programmatically from changing reference data.

> [card] [Dynamic union tables](https://docs.cube.dev/recipes/data-modeling/dynamic-union-tables.md)
>
> Combine multiple database tables that relate to the same entity into a single cube.

> [card] [Querying across data sources](https://docs.cube.dev/recipes/data-modeling/cross-data-source-queries.md)
>
> Union, join, and query views over cubes in different databases through the SQL API.

> [card] [Custom ordering](https://docs.cube.dev/recipes/data-modeling/custom-order.md)
>
> Define a custom sort order for categorical values like pipeline stages that don't sort alphabetically.

### Calculations & Metrics

> [card] [Averages and percentiles](https://docs.cube.dev/recipes/data-modeling/percentiles.md)
>
> Model percentile-based metrics alongside averages for accurate representation of skewed distributions.

> [card] [Nested aggregates](https://docs.cube.dev/recipes/data-modeling/nested-aggregates.md)
>
> Express aggregates-of-aggregates like a median of per-group sums using joined cubes and subquery dimensions.

> [card] [Filtered aggregates](https://docs.cube.dev/recipes/data-modeling/filtered-aggregates.md)
>
> Model cross-cube filters so measures aggregate facts while respecting dimensions from related cubes.

> [card] [Share of total](https://docs.cube.dev/recipes/data-modeling/share-of-total.md)
>
> Compute each dimension member's contribution to the grand total or a fixed subtotal using multi-stage measures.

> [card] [Period-over-period changes](https://docs.cube.dev/recipes/data-modeling/period-over-period.md)
>
> Calculate week-over-week, month-over-month, and other changes over a fixed period.

> [card] [Reusable period-to-date logic](https://docs.cube.dev/recipes/data-modeling/reusable-period-to-date.md)
>
> Define WTD, MTD, QTD, and YTD logic once in a Jinja macro and apply it across measures.

### Query-time parameters

Most recipes model a metric with a fixed shape — a set interval, a set window. These
recipes instead let the data consumer choose part of the calculation *at query time*,
so one set of members serves many variations without a data-model change. To generate a
family of members at model-build time instead (the consumer then picks by choosing which
member to query), see [Dynamic data models](https://docs.cube.dev/recipes/data-modeling/using-dynamic-measures.md).

> [card] [Configurable rolling windows](https://docs.cube.dev/recipes/data-modeling/dynamic-rolling-windows.md)
>
> Let consumers choose a measure's rolling-window and time-shift interval at query time, dispatching with a switch dimension.

> [card] [Dynamic parameters](https://docs.cube.dev/recipes/data-modeling/passing-dynamic-parameters-in-a-query.md)
>
> Let consumers supply a filter value at query time and use it in a calculation without filtering the entire query.

### Time Series & Calendars

> [card] [String time dimensions](https://docs.cube.dev/recipes/data-modeling/string-time-dimensions.md)
>
> Work around non-timestamp time columns by casting strings to proper time dimension types.

> [card] [Custom granularities](https://docs.cube.dev/recipes/data-modeling/custom-granularity.md)
>
> Implement custom time dimension granularities like fiscal quarters or custom week definitions.

> [card] [Custom calendars](https://docs.cube.dev/recipes/data-modeling/custom-calendar.md)
>
> Model a 4-5-4 retail calendar as a calendar cube that overrides the month, week, and year granularities.

> [card] [Data snapshots](https://docs.cube.dev/recipes/data-modeling/snapshots.md)
>
> Build point-in-time snapshots from change-history data to report status as of any date.

### User & Event Analytics

> [card] [Active users (DAU, WAU, MAU)](https://docs.cube.dev/recipes/data-modeling/active-users.md)
>
> Measure customer engagement with daily, weekly, and monthly active user metrics.

> [card] [Event analytics](https://docs.cube.dev/recipes/data-modeling/event-analytics.md)
>
> Turn raw clickstream events into session definitions and metrics for product analytics.

> [card] [Retention analysis & cohorts](https://docs.cube.dev/recipes/data-modeling/cohort-retention.md)
>
> Implement cohort-based retention analysis to track user engagement over time.

## Pre-Aggregations

> [card] [Non-additive measures](https://docs.cube.dev/recipes/pre-aggregations/non-additivity.md)
>
> Accelerate averages, distinct counts, and similar non-additive measures with pre-aggregations.

> [card] [Incremental builds](https://docs.cube.dev/recipes/pre-aggregations/incrementally-building-pre-aggregations-for-a-date-range.md)
>
> Rebuild only the time-bounded partitions you need instead of refreshing entire rollups.

> [card] [Disabling pre-aggregations](https://docs.cube.dev/recipes/pre-aggregations/disabling-pre-aggregations.md)
>
> Conditionally disable pre-aggregations based on environment or deployment context.

> [card] [original\_sql and rollups](https://docs.cube.dev/recipes/pre-aggregations/using-originalsql-and-rollups-effectively.md)
>
> Materialize expensive SQL once with original\_sql, then reuse across rollup pre-aggregations.

> [card] [Refreshing partitions](https://docs.cube.dev/recipes/pre-aggregations/refreshing-select-partitions.md)
>
> Partition-level refresh patterns for when dimension values change after initial load.

> [card] [Multiple data sources](https://docs.cube.dev/recipes/pre-aggregations/joining-multiple-data-sources.md)
>
> Join data from different warehouses with cross-database rollup joins.

> [card] [Mixed refresh cadences](https://docs.cube.dev/recipes/pre-aggregations/mixed-refresh-cadences-rollup-join.md)
>
> Combine a slow-changing fact rollup with a frequently-refreshed lookup rollup using a rollup join.

## Configuration

> [card] [Environment variables](https://docs.cube.dev/recipes/configuration/environment-variables.md)
>
> Reference deployment secrets and tunables from environment variables in your config.

> [card] [SSL connections](https://docs.cube.dev/recipes/configuration/using-ssl-connections-to-data-source.md)
>
> Enable TLS to upstream databases with custom CA bundles and client certificates.

> [card] [Optimizing data source usage](https://docs.cube.dev/recipes/configuration/data-store-cost-saving-guide.md)
>
> Reduce warehouse spend through pre-aggregation strategy and workload-aware settings.

> [card] [Custom data source per tenant](https://docs.cube.dev/recipes/configuration/multiple-sources-same-schema.md)
>
> Route each tenant to its own database while reusing a single data model.

> [card] [Custom data model per tenant](https://docs.cube.dev/recipes/configuration/custom-data-model-per-tenant.md)
>
> Give each tenant a unique data model, from completely different to partially shared schemas.

## APIs & Frontend

> [card] [Unique values for a field](https://docs.cube.dev/recipes/core-data-api/getting-unique-values-for-a-field.md)
>
> Power filter dropdowns by querying distinct dimension values from Cube's data APIs.

> [card] [Numeric values on the front-end](https://docs.cube.dev/recipes/core-data-api/cast-numerics.md)
>
> Coerce REST (JSON) numeric strings into JavaScript numbers, with precision pitfalls and caveats.

> [card] [Custom sorting](https://docs.cube.dev/recipes/core-data-api/sorting.md)
>
> Sort query result sets by custom criteria beyond default ordering.

> [card] [Pagination](https://docs.cube.dev/recipes/core-data-api/pagination.md)
>
> Implement paged tables over Cube queries using limit, offset, and deterministic ordering.

> [card] [Drilldowns](https://docs.cube.dev/recipes/core-data-api/drilldowns.md)
>
> Configure drill members and fetch detail rows behind an aggregate value.

> [card] [Real-time data fetch](https://docs.cube.dev/recipes/core-data-api/real-time-data-fetch.md)
>
> Build live-updating dashboards using WebSocket transport and client subscriptions.

## AI

> [card] [Agent-to-agent with Chat API](https://docs.cube.dev/recipes/ai/agent-to-agent.md)
>
> Wrap the Cube Chat API as a LangChain tool so an orchestrating agent can query data on demand.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.