> For the complete documentation index, see [llms.txt](https://docs.launchboard.app/cxd/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.launchboard.app/cxd/code-web-app-data-visualization/dashboard-template-tutorial/4-creating-your-own-database-google-sheet.md).

# 4 - Creating Your Own Database (Google Sheet)

⚠️  Important Note: This page was updated significantly August 30, 2021 to fix a new problem with loading spreadsheet data.

{% embed url="<https://www.loom.com/share/e766ac26fb444fa3ab140b13e2992525>" %}

{% hint style="info" %}
For reference, when you want to find real-world data, consider using this resource.

<https://www.freecodecamp.org/news/https-medium-freecodecamp-org-best-free-open-data-sources-anyone-can-use-a65b514b0f2d/>
{% endhint %}

### 1 - Create a Google Sheets File and Add Data

Create a Google Sheet file then create a simple table, like below, that could be used for a Scatter Chart. Also, name your individual sheet (the tab at the bottom) something like "myData".

| x | y |
| - | - |
| 3 | 4 |
| 4 | 6 |

### 2 - Publish Your Google Sheets File

Create a Google Sheets file and publish it by selection `file`>`Publish to the web...` then click the *Publish* button.&#x20;

### 3 - Get the Public Link for a Table

Next click select the *tab name* you want to access and choose *Comma-separated values (.csv).* Then **copy the link provided**. See the image below for an example the selects a "Degrees" tab and Comma-separated values.. \ <img src="https://2949176755-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LVJKzO0XfHZ3WnzL_Ug%2F-MiNWJCbFe5DnOy1DazM%2F-MiNYrHdMi1T40zAWWn5%2Fimage.png?alt=media&amp;token=3b406449-4d78-4457-b18c-882468e1a205" alt="" data-size="original">&#x20;

### 4 - Load Your Table in Javascript

Copy the code below and paste it just after this line. Now replace the link with your table link copied in the previous step and change the tab label (e.g. 'myData') to match your sheet tab label. You can change the `composeMyCharts` function name as you wish or keep it the same.

```javascript
viz.loadTable('https://docs.google.com/spreadsheets/d/e/2PACX-1vQUwF7K2lCH8CxQPJW-X7NqENwuwUM4eAeNUKw3j6yppO0tipC6yUB2hQPtRBZf19mmVbM5TdkkengZ/pub?gid=1030028695&single=true&output=csv', 'myData')
    .then(composeMyCharts);
```

Now you can access your database in your SQL statements. Remember that your individual sheet names are the tables you can select from in SQL. So if you want to get all the columns from a sheet (table) called "myData", then you would use the following:`SELECT * FROM myData`

### 5 - Create Charts from Your New Table

Create a function in your Javascript that will then define the charts for your new table. You can use the example below as a template, but you want the ensure the function name used in step 3 (e.g. composeMyCharts) matches this function name. You will also want to change the SQL and ensure that you have HTML elements with ID's to display the charts.

```javascript
function composeMyCharts() {
  viz.chart({
    sql:"SELECT x, y FROM myData",
    chartType:"ScatterChart",
    containerId:"chart1"
  });

  viz.chart({
    sql:"SELECT * FROM myData",
    chartType:"Table",
    containerId:"chart2"
  });
}
```

{% hint style="warning" %}
For any additional tables (Spreadsheet Tabs) you want to incorporate, you will repeat steps 2 through 5 above with the appropriate link, tab name, and additional function for composing charts.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.launchboard.app/cxd/code-web-app-data-visualization/dashboard-template-tutorial/4-creating-your-own-database-google-sheet.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
