> For the complete documentation index, see [llms.txt](https://university.gonexa.fr/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://university.gonexa.fr/doc/en/advanced-features/related-templates/create-related-chart.md).

# Create a related chart

This related template is a technical appendix used to create charts from Excel data and display them in a Word or PowerPoint document.

**Case study**

This related template is a technical appendix used to create charts from Excel data and display them in a Word or PowerPoint document.

{% hint style="info" %}
**Prerequisites**

* Use package version Grenoble 2.3
* Have a document template and know how to manage tables and Excel documents with Gonexa
* Check that the "Graph" picklist value is available; otherwise, follow the procedure below
  {% endhint %}

## Add the "Graph" picklist value if it is not visible

* From Setup, go to Object Manager > Document Template > Fields & Relationships
* Search for the Type field (`gnx_Type__c`)
* If the "Graph" value is missing, click "New" (Values), name it "Graph" and save
* Go to the "Record Types" tab, edit the picklist available for the Type field, and move the "Graph" value from Available to Selected. Save

## Create a related template of the Graph type

* From your main document template, go to the "Doc" tab and the "Related templates" block
* If needed, create child objects to generate charts on related objects (e.g. Contract + Contract Lines)
* Click "New related template" and name it (e.g. Charts)
* Select the template type: Chart (Excel)
* The "Main template object selection" field is filled in by default
* Click "Choose"

![Creating a related template of the Graph type](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/Tia5cBagnmly1r3aN5y6/33-06-creer-associe-graph.gif)

## Create the Excel file

* Create an Excel file with the fixed and dynamic parts, and add the data tables through the "Insert" > "Table" ribbon so that they are properly defined as Excel Tables
* Add the header and tags as in a standard child table
* Create the charts by selecting the relevant table, then go to the "Insert" tab > "Chart"
* Name your chart
* Select the table and give it a name in the "Table" tab; it must be identical to the name of the corresponding chart
* Add a title and a legend to each chart
* Click the chart and set a unique name for each chart in the "Name Box"

{% hint style="success" %}
**Example**

A table named "GraphA" and a chart named "GraphA"\
A table named "GraphB" and a chart named "GraphB"
{% endhint %}

![Creating the table and the chart in Excel](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/mq8FOwGkcusZe7XhsZi6/34-08-excel-graph-1.gif)

![Naming tables and charts in Excel](https://4198981723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTYUzkIngX1MnHE8kOJDR%2Fuploads%2FIczHXumhzfidtDsbFn8T%2Fmodeles-associes-3.png?alt=media)

## Insert the chart into the main document

* In Salesforce, from the Main templates block, go to your main template
* Open the main document (Word or PowerPoint)
* Place the tag where you want to insert the chart

![Inserting the chart tag in the document](https://content.gitbook.com/content/U1Chwyf7Cc7FN9BiEh0V/blobs/cPrRsrUJb55uJFJaU4X8/35-09-excel-dans-doc.gif)

**The Chart tag**

Tag syntax: `{!gnxgraph|Nom_du_graph(w=100)}`

**Parameters:**

* **Nom\_du\_graph** = the exact name of the chart in Excel
* **w=200** = sets the chart width in pixels

{% hint style="success" %}
**Example**

The tag `{!gnxgraph|GraphA(w=150)}` uses the exact name of the chart in Excel and displays the chart at a reduced width of 150 pixels
{% endhint %}

{% hint style="danger" %}
**Warning**

The table name must be exactly the same as the chart name\
Displaying a table and its chart on the same Excel sheet lets the chart rows be updated
{% endhint %}

![Chart tag in the main document](https://4198981723-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FTYUzkIngX1MnHE8kOJDR%2Fuploads%2FDu1hz3U0AtllA7dUlK25%2Fmodeles-associes-4.png?alt=media)


---

# 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://university.gonexa.fr/doc/en/advanced-features/related-templates/create-related-chart.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.
