# Change Data Source

The **Change data source** feature lets you replace the primary data source of an existing sheet from the **Model** tab.

You can start this flow on an existing sheet even after you have already configured elements such as charts, pivot tables, grouping, filters, formulas, lookup columns, and mapping columns.

## 1. Before you start

Important notes:

* The feature is available from the **Model** tab of a sheet.
* It is not available for **multi-sheets**.
* The current data source is shown in the dialog for reference.
* The current data source does not appear in the selection list.
* Any supported KAWA data source type can be used.
* Returning a sheet to its original data source after switching away from it is currently not supported.

## 2. Open the Change data source dialog

1. Open the sheet.
2. Go to the **Model** tab.
3. Click **Change data source** in the toolbar.

<figure><img src="https://2701963830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6wXylCyyATfFd8yjjWTn%2Fuploads%2F2mwSHYf3a4dYeNliiDFM%2Fchange_data_source1.png?alt=media&#x26;token=bff477e9-2571-4fa0-919f-1610408b3bf0" alt=""><figcaption></figcaption></figure>

*The **Change data source** button is available from the **Model** tab of a sheet.*

KAWA opens a 3-step dialog:

1. **Select source**
2. **Map columns**
3. **Review**

## 3. Step 1 — Select source

In the first step, KAWA shows:

* the current data source
* a searchable list of available replacement data sources
* the number of columns in each source
* whether a source is incompatible
* how many additional columns will be added to the sheet

Data sources with fewer columns than the current one appear as **incompatible**.

Select the new data source and click **Next**.

<figure><img src="https://2701963830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6wXylCyyATfFd8yjjWTn%2Fuploads%2F9AEvNgw8gLpSXxnoujEI%2Fchange_data_source2.png?alt=media&#x26;token=5d085aaa-e6ce-4973-b2c3-1a7557330643" alt=""><figcaption></figcaption></figure>

*Select a replacement data source and review compatibility before continuing.*

## 4. Step 2 — Map columns

In the mapping step, every column from the current primary data source must be mapped to one column in the new data source.

KAWA automatically matches columns when their **name** and **type** match.

Rules for mapping:

* all current-source columns must be mapped before you can continue
* columns of different types cannot be mapped to each other
* the same new column cannot be mapped to multiple current columns
* the mapping must be **1:1**

If the new data source contains additional columns that are not used in the mapping, those columns are added to the sheet automatically.

After completing the mapping, click **Next**.

<figure><img src="https://2701963830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6wXylCyyATfFd8yjjWTn%2Fuploads%2FeQTpoq6t30OQ27XvrY6I%2Fchange_data_source3.png?alt=media&#x26;token=616fa45a-2d7a-4ccd-8718-3055b95bd3e8" alt=""><figcaption></figcaption></figure>

*Map each current column to a matching column in the new data source.*

## 5. Step 3 — Review

In the review step, KAWA shows:

* the current data source and the new data source
* the number of mapped columns
* the list of new columns that will be added to the sheet

Review the change carefully before applying it.

> New columns will be added to the sheet. This action cannot be undone.

Click **Apply** to update the sheet model.

<figure><img src="https://2701963830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6wXylCyyATfFd8yjjWTn%2Fuploads%2FsAfmO8ZkO8Xfw6yWogLj%2Fchange_data_source4.png?alt=media&#x26;token=0559a463-9750-4972-99a8-dd01b08bc81e" alt=""><figcaption></figcaption></figure>

*Review the selected source, mapped columns, and new columns before applying the change.*

## 6. Example

Suppose your sheet is currently based on `cities_basic.csv` with the following columns:

* `id`
* `city`

You change the sheet to `cities_with_population.csv`, which contains:

* `id`
* `city`
* `population`

In this case:

* `id` is mapped to `id`
* `city` is mapped to `city`
* `population` is added to the sheet automatically

For example, the original data source may look like this:

| id | city       |
| -- | ---------- |
| 1  | Amsterdam  |
| 2  | Berlin     |
| 3  | Copenhagen |
| 4  | Dublin     |
| 5  | Edinburgh  |

The new data source may look like this:

| id | city       | population |
| -- | ---------- | ---------- |
| 1  | Amsterdam  | 921402     |
| 2  | Berlin     | 3644826    |
| 3  | Copenhagen | 667099     |
| 4  | Dublin     | 592713     |
| 5  | Edinburgh  | 506520     |

After the change:

* `id` remains mapped to `id`
* `city` remains mapped to `city`
* the new `population` column is added to the sheet automatically

<figure><img src="https://2701963830-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F6wXylCyyATfFd8yjjWTn%2Fuploads%2FRI8CYJPoqJ3u3EKWFFXj%2Fchange_data_source5.png?alt=media&#x26;token=691796db-3835-44d5-b09b-11859a01649f" alt=""><figcaption></figcaption></figure>
