> For the complete documentation index, see [llms.txt](https://docs.infotopics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.infotopics.com/trulyp/data/semantic-modeling.md).

# Semantic modeling

A semantic model turns a database table into something your users understand: friendly names, descriptions, the right data types and only the columns that matter. Analytics, SuperTables and other extensions work with semantic models instead of raw tables, so you define all this once and every dashboard benefits.

You manage semantic models in **Data** › **Semantic models**. You need the **Semantic manager** role, or be an administrator.

<figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2Fgit-blob-667cf1a479a8f8a8ff422c6e6f2914eee6a70122%2FData_Models_List.png?alt=media" alt=""><figcaption><p>Data › Semantic models</p></figcaption></figure>

The list shows each model's **Name** and description, and the number of **Tables**. Models imported from a semantic provider show a **Semantic provider based** badge. Use the pencil to open a model, and the download icon to [export it](#export-and-import-a-semantic-model).

{% hint style="info" %}
**Who can use a model?** A semantic model is available to the teams of the connection or semantic provider it's built on. To change who can use it, change the teams of that connection or provider.
{% endhint %}

### Two kinds of semantic models

* **Connection-backed model**: built on one of your [connections](/trulyp/data/database-connections.md). You choose the table and tune it in Trulyp.
* **Semantic provider import**: imported from a [semantic provider](/trulyp/data/semantic-providers.md), such as a Tableau published data source through VDS. Its structure is managed in Tableau.

### Create a connection-backed model

{% stepper %}
{% step %}

### Name your model

Click **Create new semantic model**. Under **Model details**, enter a **Model name** and a short **Description** that tells people what the model contains.
{% endstep %}

{% step %}

### Choose the table

Under **Table selection**, keep **Model source** on **Connection-backed model** and choose the **Connection**. Its tables and views appear below; use **Filter tables** to find yours. Click a table, or drag it onto the **Model canvas**.

{% hint style="warning" %}
A semantic model currently holds **one table**. Need data from several tables? Create a view in your database that combines them, and use the view.
{% endhint %}
{% endstep %}

{% step %}

### Tune the table and its columns

On the canvas, the table shows its columns and their types; `PK` marks the primary key. Click the pencil on the table to give it a friendly **Alias** and a **Description**, and the pencil next to a column to edit that column (see [below](#edit-a-column)).
{% endstep %}

{% step %}

### Save

Click **Save semantic model**. After saving, the **Data preview** shows the first rows from your table.
{% endstep %}
{% endstepper %}

<figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2Fgit-blob-75ca9a1b0a4f99e3a641359f9f8464f607065e47%2FData_Model_Editor_Full.png?alt=media" alt=""><figcaption><p>A connection-backed model with its canvas and data preview</p></figcaption></figure>

### Edit a column

Click the pencil next to a column, on the canvas or in the column header of the **Data preview**:

* **Alias**: the name people see, for example `Order date` instead of `order_dt`. **Reset alias** goes back to the column name.
* **Comment**: a description of the column. Analytics and Vizzy AI use it to understand your data, so a good comment pays off.
* **Analytics data type**: see the next section.
* **Hidden**: hide the column from Analytics and extensions, for example for technical columns.

Click **Save** in the dialog, and then **Save semantic model**.

<div><figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2Fgit-blob-326423b76e060deda16d591aca9bed69c0115ffd%2FData_Model_Edit_Table.png?alt=media" alt=""><figcaption><p>Edit table</p></figcaption></figure> <figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2Fgit-blob-d00770cafd6390bfb4a87ca31bc09be29d949fb6%2FData_Semantic_Model_Edit_Column_Analytics_Data_Type.png?alt=media" alt=""><figcaption><p>Edit column</p></figcaption></figure></div>

### Changing how Analytics treats a column

By default, Analytics uses the data type from your source. Some columns are stored as numbers but should not be summed or averaged, for example postal codes, customer numbers or year codes. You can tell Analytics to treat these columns as **Text**:

1. Open the semantic model and click the pencil icon next to the column, either on a table in the **Model canvas** or in the column header of the **Data preview**.
2. Under **Analytics data type**, choose **Text** instead of **Use source type**.
3. Click **Save**, and then **Save semantic model**.

On the model canvas, overridden columns show their type as **Text** in blue. Hover over the type to see the original source type. The data in your database is not changed, and the setting is kept when you export and import the semantic model.

{% hint style="warning" %}
Text fields use text filtering and sorting. If a visual already uses this column with a numeric aggregation such as **SUM**, you may need to remove that aggregation.
{% endhint %}

### Data preview and semantic profile

* **Data preview** shows the first five rows of the saved model. Click **Refresh** after you change the model and save it again.
* **Semantic profile** shows how Trulyp interprets your fields, based on a sample of the data: how many are **Dimensions**, **Measures** or **Unknown**, and what each field likely means. When a column has no comment yet, Trulyp adds the description it inferred as its comment.

### Import from a semantic provider

Have a [semantic provider](/trulyp/data/semantic-providers.md) set up? Then you can use a Tableau published data source as a semantic model:

1. Click **Create new semantic model** and enter a **Model name**.
2. Set **Model source** to **Semantic provider import**.
3. Choose the **Semantic provider** and the **Datasource**.
4. The model shows the data source's tables and relationships. Click **Save semantic model**.

<figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2FFsow8lBjkL4pJNJ0RtPn%2Fimage.png?alt=media&amp;token=8f8e1ca0-281b-491a-b340-4fe8ca46295b" alt=""><figcaption></figcaption></figure>

The structure of an imported model is managed in Tableau: you can't change its tables or columns in Trulyp. To change it, update the data source in Tableau and import it again.

{% hint style="warning" %}
Changing the provider or data source of an existing model can break the dashboards that use it.
{% endhint %}

### Export and import a semantic model

Want the same model in another Trulyp environment, for example from test to production? Export it and import it there.

* **Export**: click the download icon next to a connection-backed model. You get a `.json` file with the model's tables, columns, aliases, comments and settings. Connection settings and credentials are **never** included.
* **Import**: click **Import semantic model** and choose the file. Then select the destination connection for each connection the model used; Trulyp suggests a match by name. Click **Import semantic model** and the new model opens.

<figure><img src="https://2312557015-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FWbWxEBax8PKTjFYRLWgi%2Fuploads%2Fgit-blob-da4bb0087d56f0877072cc4066390870170521a6%2FData_Models_Import.png?alt=media" alt=""><figcaption></figcaption></figure>

Models imported from a semantic provider can't be exported this way.

### Delete a semantic model

Open the model and click **Delete semantic model**. Make sure no dashboards use it anymore: Trulyp doesn't check this for you, and dashboards that use a deleted model stop working.

{% hint style="info" %}
**Large tables:** for connection-backed models, Trulyp caches totals and grand totals of large tables for a few minutes, so it doesn't have to query your database each time.
{% 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.infotopics.com/trulyp/data/semantic-modeling.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.
