> For the complete documentation index, see [llms.txt](https://docs.myjuicebox.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.myjuicebox.io/building-reports/story-designer/slices/dynamic-text.md).

# Dynamic text

Slice text can change dynamically based on what a user has selected in slices above.

{% hint style="info" %}
It is best practice to add dynamic text after configuring charts. Dynamic text will only return selections in charts.
{% endhint %}

For example, suppose you have a [chooser](/building-reports/story-designer/slices/charts/data-card.md) slice followed by a [trend](/building-reports/story-designer/slices/charts/trend.md) slice, and the measure used in the trend slice is the measure selected in the upstream chooser slice. Your trend slice title says "Here's the trend for **the measure selected above**":

![The trend slice has a static title. Let's make it dynamic.](https://872636700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmfYn9Ab4YpIl0ZZFm-%2Fuploads%2F4muCL1IHPZdp4f2xbtar%2Fimage.png?alt=media\&token=4e30db81-38b5-4273-ab1e-1ba516d11e66)

You want to replace the phrase "the measure selected above" with the label of the measure selected above. For example, If the user selects **IMDb Rating** in the chooser slice, you want the trend slice title to display "Here's the trend for **IMDb Rating**." Likewise, if the user selects **Budget**, you want the trend slice title to display "Here's the trend for **Budget**" (and so on).

To do this, you would replace "the measure selected above" in the slice text area with dynamic text that references the chooser slice. Clicking the "@" button in the chooser slice will copy the dynamic text reference (also called the "slice slug"), which you can then paste into the downstream slice text.

![The trend slice now has dynamic text that displays the selection made in the measure chooser slice](https://872636700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmfYn9Ab4YpIl0ZZFm-%2Fuploads%2FKikhplzRaWINWITWAcZ4%2Fimage.png?alt=media\&token=8a7ba56e-c19c-4db2-a0d4-4a234b81b6b8)

Here's what that looks like:

{% embed url="<https://www.loom.com/share/5e0455cac13341deac414ab5585a8a43>" %}
Add dynamic text
{% endembed %}

### More dynamic text shortcuts

You can access other details about a slice with the following shortcuts.

| Shortcut      | Description                                                            |
| ------------- | ---------------------------------------------------------------------- |
| @Slice.pill   | Display a selectable pill that lets you change the selection in Slice. |
| @Slice.label  | Show a label for what kind of item is being selected in Slice.         |
| @Slice.list   | List the selections in Slice.                                          |
| @Slice.count  | Show the total number of unique items in Slice.                        |
| @Slice.number | Show the total number of selected items in Slice                       |

Here's an example

We have a slice that lets you look at a leaderboard of Directors using the Movie Trends data.

<figure><img src="https://872636700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmfYn9Ab4YpIl0ZZFm-%2Fuploads%2Fl5NUiPecUxem5S7ys6m5%2Fimage.png?alt=media&amp;token=53d6fa47-61d3-41da-8eda-d6a24fcccdff" alt=""><figcaption><p>This slice is Leaderboard1</p></figcaption></figure>

We can use the dynamic text below to show and change details about what is selected. Here's the text

<_@Leaderboard1.number> selected out of @Leaderboard1.count @Leaderboard1.label\_

*The selections are @Leaderboard1.list*

*Change them yourself here @Leaderboard1.pill*

Here's what this looks like.

<figure><img src="https://872636700-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-LmfYn9Ab4YpIl0ZZFm-%2Fuploads%2FnPA07nmYCHcYngFo9BXr%2Fimage.png?alt=media&amp;token=0a9784b9-1e09-410c-9009-6454b3973eaf" alt=""><figcaption></figcaption></figure>


---

# 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.myjuicebox.io/building-reports/story-designer/slices/dynamic-text.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.
