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

# Multi-source charts

> Join query results from several data sources in one chart

A multi-source chart runs a query on each of several data sources and joins the results into one chart. Use it to combine data that lives in different places, such as revenue from Stripe in Basedash Warehouse and accounts from your production Postgres database.

<Note>
  Multi-source charts are in beta and may not be enabled for your organization
  yet. Contact [support@basedash.com](mailto:support@basedash.com) to request
  access.
</Note>

## Overview

A regular [chart](/docs/features/charts) runs one SQL query against one data source. A multi-source chart has:

* **Source queries**: one query per data source, written in that data source's SQL dialect. Each result gets a name, called an alias.
* **A join query**: a [DuckDB](https://duckdb.org/docs/sql/introduction) SQL query that combines the source results by their aliases.

Basedash runs each source query, loads the results into DuckDB in memory, and runs the join query. The chart shows the result of the join query.

If the data you want to combine is in one data source, use a regular chart. It's faster and has fewer limits.

## Create a multi-source chart

1. Open a chart in the chart editor. See [Use the chart editor](/docs/features/charts#use-the-chart-editor).
2. Click **Add source** in the toolbar. The editor switches to tabs: one tab per source query, plus a **Join** tab.
3. In each source tab, choose a data source and write a query that returns only the rows and columns you need. Double-click a tab to rename its alias, for example `accounts` or `payments`.
4. Click **Add source query** to add more sources.
5. Open the **Join** tab and write a DuckDB query that combines the sources by alias. The schema sidebar lists the tables available to the join query.
6. Click **Run**, then choose the chart type and settings as usual.

For example, with source queries aliased `accounts` and `payments`:

```sql theme={"dark"}
SELECT
  accounts.plan,
  SUM(payments.amount) AS revenue
FROM accounts
JOIN payments ON payments.customer_id = accounts.stripe_customer_id
GROUP BY 1
ORDER BY 2 DESC
```

To remove a source, select its tab and click **Remove selected source**.

## Limits

<Note>
  * Up to 8 source queries per chart, from at least 2 different data sources. -
    Each source query can return up to 50,000 rows and 25 MB. All sources together
    can return up to 50 MB. - Aliases must start with a letter or underscore and
    contain only letters, numbers, and underscores (up to 63 characters). - If any
    source query fails, the chart shows an error instead of a partial result. -
    Drilldowns and data export aren't available on multi-source charts.
</Note>

If a source returns too many rows, you'll see an error like `Source "payments" returned more than 50,000 rows`. Aggregate or filter in the source query before joining, for example by grouping payments by customer.

## FAQ

<AccordionGroup>
  <Accordion title="Which data sources can I combine?">
    Any data sources you can query, including databases, warehouses, and
    Basedash Warehouse. Each source query uses its own SQL dialect, and the join
    query always uses DuckDB SQL.
  </Accordion>

  <Accordion title="Do access rules still apply?">
    Yes. Each source query runs with your [data source
    access](/docs/administration/data-source-access-control) and [row-level
    security](/docs/administration/row-level-security), just like a regular chart.
  </Accordion>

  <Accordion title="Can the AI build multi-source charts?">
    Yes. When multi-source charts are enabled, ask [chat](/docs/features/chat) or the
    dashboard chat for a chart that combines data from several sources, and the
    AI writes the source queries and the join query for you.
  </Accordion>
</AccordionGroup>

## Related

* [Charts](/docs/features/charts)
* [Models](/docs/features/models)
* [Basedash Warehouse](/docs/data-sources/warehouses/basedash-warehouse)


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