Dynamic text is user-built data-driven text that is linked to a data discovery. The text includes dynamic PQL or MDX functions in order to obtain and display the required information. When the publication is rendered, the dynamic text will show the current data-driven values of the given dynamic functions.
Navigate the Dynamic Text Editor
With your text box selected, click the Dynamic Text button (purple highlight below) to open the Dynamic Text Builder. Alternatively, open the Dynamic Text drop-down button to build dynamic place holders, or add dynamic text fields.
From the Dynamic Text Editor:
- Open the Content drop-down (orange highlight below) and select the required grid that will be queried.
- Write your dynamic text expression in the script editor (red highlight).
- Use the PQL Functions library (yellow highlight) to add SQL expressions to your script.
- Select the relevant cells from the grid (purple highlight) to populate the given PQL expressions,
The Pyramid Query Language or PQL (pronounced 'Prequel') is a language built into Pyramid's PYRANA engine to allow users to construct queries that can run against the many SQL data stacks that Pyramid can query natively. PQL includes a vast array of operations and functions that allows users to query data and build analytical logic.
The Dynamic Text Editor exposes Dynamic and Common functions. Dynamic functions are a set of specialized method that are designed to act on a given query 's result set. Common functions are a set of methods that are found in most programmatic and mathematical function libraries. These functions are used to perform logic on basic data without concern for data structures, context, or even source.
To add a PQL function from the library to the script editor, simply double click on it. You will then need to inject values into the function.
You can build dynamic text from within Publish, in order to add dynamic text on an ad-hoc basis.
Add a textbox to the page by clicking the Text icon in the canvas menu. In the textbox, write the required text.
Remove the words that should be dynamic, and place the cursor in the space where the dynamic text should appear. Click the Dynamic Text button from the Component ribbon. In the Content panel, find and select the content you want to base your dynamic text on.Once selected, the grid or visual area will appear in the editor.
Select the relevant cell, and apply any relevant query, math, or date functions and define the format. Test your dynamic text, and then click Apply. If you have multiple dynamic elements in the text, configure each one separately.
Your dynamic text will be added to the page.
Pyramid's OpenAI integration enables you to use AI to generate scripts and images, dynamic text and infographics, calculations and lists, schedules, colors, and more. This allows you to generate a range of content, including complex code, by simply providing a text prompt.
Use the ChatGPT AI-driven PQL function (from the Common PQL functions) to generate dynamic text. While this function cannot tell you about your data set, it can add additional information and background to your presentation. You can also use your data to drive the results generated by OpenAI's ChatGPT by creating interactions between visualizations and/ or slicers, and the dynamic text where the ChatGPT PQL function is injected.
Warning: AI-generated assets are generated from public domain algorithms, which can produce both erroneous and inconsistent/ random results. Use at your own risk.
- Click here to learn about slicers.
In this example, an interaction was added from a Country slicer to both the Map visualization and the dynamic text, driven by the Chat GPT function. The result is that both the visual and the dynamic text are simultaneously filtered by the same slicer, so that the dynamic text returns a result based on the given country.
When the publication is rendered, it returns results for the selected slicer element:
The dynamic text is written against a simple grid containing the same country hierarchy that comprises the slicer.
The expression entered in the script window (purple highlight below) is as follows:
ChatGPT("what landmarks is " + label(1,0,0) + " famous for.")
From the Interaction Manager, interactions were added from the slicer (yellow highlight below) to both the visual and the dynamic text (red highlight below).
When the publication is rendered and the given slicer is applied, the underlying grid will be filtered to include only a single row (the country selected from the slicer). The dynamic text expression will then return a description of landmarks for the given country.
Users requiring dynamic text from disparate data based on multiple queries can use Tabulate as the source for the dynamic text. Tabulate allows you to blend queries from multiple data sources into a single Tabulation. You must then define a Visual Area that can be used as a single data source for the dynamic text. The Visual Area can then be used as a source for the data grid that the dynamic text is based on.
In Tabulate, drag and drop different queries onto the canvas. In this example Sales and Returns is dropped on the left hand side of the Tabulate canvas and the Expenses and Margin query is dropped on the right hand side of the canvas.
Select the required area including both queries.
Set the Visual Area by clicking on the Set Visual Area button from the Visual Area drop-down on the Tabulate ribbon, name the visual area and save the Tabulate worksheet
Note that you must save the Visual Area in the Tabulation and the Tabulate worksheet in order to use it in an Illustrate item.
Build your dynamic text (as per previous example), select the Visual Area as the source for the data grid.
From the Content drop down, select the Country Sales and Expenses Tabulate item, then select the Visual Area - "Sales_And_Expenses". This will be used as the data grid for the dynamic text.
You can now use any data from the Visual Area in your dynamic text. In this dynamic text formula (orange box) we have subtracted New South Wales Expenses (green box) from New South Wales sales (red box). The result of $47,051.61 can be seen in the dynamic text (orange box). This demonstrates how data from disparate sources can be used to generate dynamic text.