> ## 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.

<img src="https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-configuration.png?fit=max&auto=format&n=0pAPZ_aPFgZJqHZJ&q=85&s=a0e587b6d80b3af864c72f491e7e9215" alt="Cube configuration interface showing a list of cubes, measures and dimensions for the selected cube, and query execution controls with result preview." className="rounded-xl border border-gray-200 shadow-md hover:shadow-2xl transition-all duration-300" width="1918" height="983" data-path="images/knowledge-bases/cube-configuration.png" />

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.
</Tip>

## Create a new cube

<img src="https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/add-cube.png?fit=max&auto=format&n=0pAPZ_aPFgZJqHZJ&q=85&s=906fbdb360324f4eeb77a6dba3592630" alt="Add Cube modal showing two creation approaches: AI Generate and Manual Query." className="rounded-xl border border-gray-200 shadow-md hover:shadow-2xl transition-all duration-300" width="1918" height="983" data-path="images/knowledge-bases/add-cube.png" />

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.

<Steps>
  <Step title="Enter a cube name">
    Provide a unique, descriptive identifier, for example `ORDER_SUMMARY` or `MONTHLY_REVENUE`.
  </Step>

  <Step title="Write a description">
    A concise explanation of the cube's analytical purpose.
  </Step>

  <Step title="Describe the analytics in natural language">
    Tell the AI what you want to analyse, for example "Show total revenue by region and product category, with month-over-month trends."
  </Step>

  <Step title="Provide business context">
    Add domain context so the AI can make better decisions about joins, filters, and metric definitions.
  </Step>
</Steps>

<img src="https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-ai-generation.png?fit=max&auto=format&n=0pAPZ_aPFgZJqHZJ&q=85&s=ed6d5a3f79f773ab6eb9f79e2d1d1c46" alt="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." className="rounded-xl border border-gray-200 shadow-md hover:shadow-2xl transition-all duration-300" width="1918" height="983" data-path="images/knowledge-bases/cube-ai-generation.png" />

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.

<Steps>
  <Step title="Enter a cube name">
    Provide a unique identifier for the cube.
  </Step>

  <Step title="Write the base SQL">
    Author a custom SQL query that defines the cube's data source.
  </Step>
</Steps>

<img src="https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-manual-flow.png?fit=max&auto=format&n=0pAPZ_aPFgZJqHZJ&q=85&s=9243a909d6301e407a3d26e67a379de3" alt="Manual Query flow for cube creation showing the Cube Name field and a SQL editor for writing custom queries." className="rounded-xl border border-gray-200 shadow-md hover:shadow-2xl transition-all duration-300" width="1918" height="983" data-path="images/knowledge-bases/cube-manual-flow.png" />

<Warning>
  Prefer AI Generate for rapid prototyping and exploratory analytics. Use Manual Query for performance-critical or highly customized analytical logic.
</Warning>

**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.

<Steps>
  <Step title="Select measures">
    Choose the metrics you want to calculate.
  </Step>

  <Step title="Select dimensions">
    Choose how to group and filter the results.
  </Step>

  <Step title="Apply filters">
    Narrow the results to a specific subset of data.
  </Step>

  <Step title="Run the query">
    Click **Run Query** to execute.
  </Step>
</Steps>

<img src="https://mintcdn.com/ideabodxai/0pAPZ_aPFgZJqHZJ/images/knowledge-bases/cube-query-execution.png?fit=max&auto=format&n=0pAPZ_aPFgZJqHZJ&q=85&s=943d3a51ddff0e24ca6156cea1c3d480" alt="Cube selection panel showing measures and dimensions dropdowns, filter controls, Run Query button, and results table." className="rounded-xl border border-gray-200 shadow-md hover:shadow-2xl transition-all duration-300" width="1918" height="983" data-path="images/knowledge-bases/cube-query-execution.png" />

### 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.
