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

# Creating and querying cubes

> Build analytical models with measures, dimensions, and queryable APIs on top of your structured data.

Cubes are analytical models built on top of structured data. They define the measures you want to calculate, the dimensions you want to group and filter by, and the SQL logic that generates the data. This guide walks you through creating cubes and executing queries.

## Understanding cubes

A cube defines three things.

| Component | Description | Example |
| - | - | - |
| **Measures** | Metrics to calculate. | Total revenue, average price, record count. |
| **Dimensions** | Attributes to group or filter by. | Date, category, region, status. |
| **SQL Logic** | The underlying query that generates the cube data. | A SELECT statement joining relevant tables. |

## Access the cube configuration interface

In the structured knowledge base view, the cube interface shows:

* A list of existing cubes in the left panel.
* The measures and dimensions of the selected cube.
* Query execution controls and a result preview.

![Cube configuration interface showing a list of cubes, measures and dimensions for the selected cube, and query execution controls with result preview.](https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-configuration.png?fit=max\&auto=format\&n=0pAPZ_aPFgZJqHZJ\&q=85\&s=a0e587b6d80b3af864c72f491e7e9215)

Click **Add Cube** to create a new one.

> [!TIP]
>
> Ensure the underlying datasets are already validated and available before creating cubes. Follow consistent naming conventions to simplify discoverability.

## Create a new cube

![Add Cube modal showing two creation approaches: AI Generate and Manual Query.](https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/add-cube.png?fit=max\&auto=format\&n=0pAPZ_aPFgZJqHZJ\&q=85\&s=906fbdb360324f4eeb77a6dba3592630)

The Add Cube modal provides two approaches.

### AI Generate (recommended)

Let AI automatically generate the base SQL, measures, and dimensions from a natural language description.

**1. Enter a cube name**

Provide a unique, descriptive identifier, for example `ORDER_SUMMARY` or `MONTHLY_REVENUE`.

**2. Write a description**

A concise explanation of the cube's analytical purpose.

**3. Describe the analytics in natural language**

Tell the AI what you want to analyze, for example "Show total revenue by region and product category, with month-over-month trends."

**4. Provide business context**

Add domain context so the AI can make better decisions about joins, filters, and metric definitions.

![AI Generate flow for cube creation showing fields for Cube Name, Description, Natural Language Query, and Business Context, with AI-generated SQL and measures below.](https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-ai-generation.png?fit=max\&auto=format\&n=0pAPZ_aPFgZJqHZJ\&q=85\&s=ed6d5a3f79f773ab6eb9f79e2d1d1c46)

The AI analyses your datasets and context to generate optimized SQL with appropriate measures and dimensions.

### Manual query

For advanced users who want to author SQL directly.

**1. Enter a cube name**

Provide a unique identifier for the cube.

**2. Write the base SQL**

Author a custom SQL query that defines the cube's data source.

![Manual Query flow for cube creation showing the Cube Name field and a SQL editor for writing custom queries.](https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-manual-flow.png?fit=max\&auto=format\&n=0pAPZ_aPFgZJqHZJ\&q=85\&s=9243a909d6301e407a3d26e67a379de3)

> [!WARNING]
>
> Prefer AI Generate for rapid prototyping and exploratory analytics. Use Manual Query for performance-critical or highly customized analytical logic.

**Best practices**

* Clearly document the business intent in the description and context fields.
* Test generated SQL before deploying to production workflows.
* Start with simple cubes and iterate based on feedback.

## Execute queries and view results

Once a cube is created, you can query it using the cube selection panel.

**1. Select measures**

Choose the metrics you want to calculate.

**2. Select dimensions**

Choose how to group and filter the results.

**3. Apply filters**

Narrow the results to a specific subset of data.

**4. Run the query**

Click **Run Query** to execute.

![Cube selection panel showing measures and dimensions dropdowns, filter controls, Run Query button, and results table.](https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-query-execution.png?fit=max\&auto=format\&n=0pAPZ_aPFgZJqHZJ\&q=85\&s=943d3a51ddff0e24ca6156cea1c3d480)

### View results in multiple formats

Query results are available in several formats via tabs.

| Tab | Description |
| - | - |
| **Results** | Interactive table or chart view of the query output. |
| **Generated SQL** | The SQL query powering the results. |
| **SQL API** | An endpoint for SQL-based integrations. |
| **REST API** | A RESTful endpoint for application integrations. |
| **GraphQL API** | A GraphQL endpoint for data fetching. |

**Best practices**

* Start with a limited number of dimensions for better performance.
* Reuse generated API endpoints instead of re-running UI queries.
* Validate results against source systems for critical analytics.
* Export and share results with your team.


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