# Dynamic Model

A Dynamic Model gets built from the data source, instantly at the click of a button. The structure of the model is taken from the categories assigned to the visual and each level adds up one over the other.&#x20;

After importing the data using the steps explained in the [Get Data](https://docs.valq.com/model/get-data) section, choose **Dynamic Model** and click **Create**.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FDhoYIpzCqKr7dyDpSEb1%2Fimage.png?alt=media&#x26;token=ea5f568d-c900-4be1-91f9-a767529bff78" alt=""><figcaption><p><strong>Creating Dynamic Model</strong></p></figcaption></figure>

{% hint style="info" %}
**Dynamic Model** option gets enabled only after you have assigned Category and Values fields to the visual.
{% endhint %}

Dynamic model gets built instantly as shown below.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2Fy6dmx5yOoerXthgAn8YQ%2Fimage.png?alt=media&#x26;token=7c09bf02-e419-42d4-a58d-be4897c4e53d" alt=""><figcaption><p><strong>Dynamic model -  Example</strong></p></figcaption></figure>

This type of model is termed dynamic as ValQ automatically updates your model whenever the categories are added, removed, or re-arranged. Since Dynamic models are flexible in nature they can be immensely useful for **scaling** your model.

{% hint style="info" %}
Refer to [this section](https://docs.valq.com/get-data#3.-assign-your-data-fields-to-valq) for more help on assigning fields to the visual.
{% endhint %}

The nodes on a dynamic model, referred to as dynamic nodes, are locked/disabled by default **except for the root node.** Ideally, you can not configure, move, or remove them.&#x20;

## Working with dynamic models

A Dynamic model can be edited while keeping its dynamic nature in the following ways.

## **1. Add Nodes to Root Node**

New nodes can be added to the root node in two ways.

1.1. Add nodes using Template

1.2. Add nodes using the 'Add New Node' option

### **1.1. Add Nodes Using Template**

In a dynamic model, new nodes can be added to the root node using templates. Refer to [this section](https://docs.valq.com/templates/apply-template#add-template-as-new-nodes) to read more about it.

Find below the image of a dynamic model with a template added using **Add New Node-> Add Node using Template.**

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FQ5d2qTQlitBmUY4EQ2UP%2Fimage.png?alt=media&#x26;token=be9639f0-2e99-4e4e-bea8-979571ab15fa" alt=""><figcaption><p><strong>Click 'Add Node using Template'</strong></p></figcaption></figure>

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2Fu7JNpWRcpFXkNbDVaj4A%2Fimage.png?alt=media&#x26;token=7334ecb6-92b3-4eaf-ac99-f2b033d325ac" alt=""><figcaption><p><strong>Dynamic Model with Added Template Nodes</strong></p></figcaption></figure>

### **1.2.** Add Nodes using the 'Add New Node' option

New child nodes can also be added to the root node using the other options available in the **Add New Node** menu. Check out the steps [here](https://docs.valq.com/model-editor/node-operations#1.-add-node) to learn how to add new nodes to the model.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FjcX0FieS8jczrMcM7brO%2Fimage.png?alt=media&#x26;token=7a88246b-188d-466e-a212-5d8a437e747d" alt=""><figcaption><p><strong>Add New Node</strong></p></figcaption></figure>

The below image shows a dynamic model with a new node added through **Add New Node-> Text.**

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FrnqLDzsKx2gj0LMNLpc9%2Fimage.png?alt=media&#x26;token=7dce8a7f-22b9-44ec-9214-4f060868a6c9" alt=""><figcaption><p><strong>New Node Added</strong></p></figcaption></figure>

## 2. Replace/Insert Nodes with Template

You can edit the dynamic model using templates by way of replacing the existing nodes or just inserting the template nodes within the model. Let us see both the ways below.

### **2.1. Replace nodes using templates**

Replacing the existing dynamic node structure with template nodes is one of the ways to edit a dynamic model, without converting it. The template nodes are introduced in relation to the existing nodes while still keeping the entire model dynamic and locked for node-level edits. To learn about replacing dynamic nodes using templates, refer to [this section.](https://docs.valq.com/templates/apply-template#1.-replace-dynamic-nodes-with-template)

Click on **Templates->Apply Template->Replace Nodes with** **Template** to replace dynamic nodes with templates.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FEdxRLPBaPYVfudLGZELz%2Fimage.png?alt=media&#x26;token=0344cae0-0649-41e8-98ba-565240b3eda1" alt=""><figcaption><p><strong>Apply Template->Replace Nodes with template</strong></p></figcaption></figure>

The below image shows a dynamic model where some nodes are replaced by template nodes as highlighted below.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2F5chGuo7YvHbHmxVjEY5M%2Fimage.png?alt=media&#x26;token=a27fcf65-7369-4f6e-84c1-dd77c3617ef0" alt=""><figcaption><p><strong>Dynamic Model replaced with template</strong></p></figcaption></figure>

### 2.2. Insert nodes using templates

Inserting template nodes at multiple levels within a dynamic model is another way to edit it. In this method, the existing dynamic nodes are not replaced but new nodes are inserted by way of templates wherever required. Refer to [this section](https://docs.valq.com/templates/apply-template#2.-insert-custom-nodes-to-the-model) to know more.

Click on **Templates->Apply Template->Insert New Nodes with** **Template** to insert nodes within the dynamic model.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FyN3UP3vRsrWU1BH8Kizg%2Fimage.png?alt=media&#x26;token=c2c4fc79-a6ba-4c12-b128-a4614c22295b" alt=""><figcaption><p><strong>Apply Template->Insert New Nodes with Template</strong></p></figcaption></figure>

In the following example, the template ‘*Pastries*’ is added to the dynamic model at each *Region* level.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2F59bILtk8G2O76bVxjyTt%2Fimage.png?alt=media&#x26;token=386de90a-5a85-43c2-a8e6-6f422d105243" alt=""><figcaption><p><strong>Dynamic model inserted with template</strong></p></figcaption></figure>

**Note:**

You can also click on the below icons to replace the nodes or insert them with template nodes.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FsqJZfF1Z5ZhxDoFBDo1N%2Fimage.png?alt=media&#x26;token=703aed1b-a5e2-4a23-b181-aa7a0a7b1ca7" alt=""><figcaption><p><strong>Replace / Insert with Template</strong></p></figcaption></figure>

## **Convert as Editable Nodes**

In this case, the model ceases to be dynamic when you convert it to an editable one. Following are the steps to convert:

In the Model Tab menu bar, choose **Convert Dynamic to Editable.**

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FVhCxrDYFtBkUj0iSUlel%2Fimage.png?alt=media&#x26;token=75afc34d-5ea7-4439-a859-69e01104340a" alt=""><figcaption><p><strong>Convert to Editable Model</strong></p></figcaption></figure>

Click **Yes** to confirm.&#x20;

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2Fqxlgt6xEw5dw1l6r1bhk%2Fconvert%20pop-up.png?alt=media&#x26;token=724096e6-1b8b-4b1e-8005-e9c0606f6e0f" alt="" width="375"><figcaption><p><strong>Convert Dynamic Model</strong></p></figcaption></figure>

The model is now converted, enabling us to edit, configure, and customize the nodes as required.

<figure><img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FqDqIcFA17vHMYm4auz5V%2Fimage.png?alt=media&#x26;token=73326d2b-67fd-44ca-9f41-6990476677c4" alt=""><figcaption><p><strong>Converted to Editable Model</strong></p></figcaption></figure>

It is recommended that the model be converted only when required and as the last option.

**Note:**

1. The template structure within the model remains unalterable. To edit the template, you can use the **Templates** menu.
2. You can use the [Undo ](https://docs.valq.com/model-editor/editor-features#5.-undo-and-redo)<img src="https://261229348-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FmXNCTvPRjJZj6UunHBgb%2Fuploads%2FB64toPPPoAVCwEks2eem%2Fimage.png?alt=media&#x26;token=1f719b60-93cd-469c-9523-0c502012f223" alt="" data-size="line">option to convert an editable model back to a dynamic model.

{% hint style="info" %}
While converting a dynamic model makes it static, it provides various options to customize the model according to your needs.
{% endhint %}

To learn how to configure the nodes, you can refer to the [Model Editor](https://docs.valq.com/model/model-editor) section.
