Adding variables and expressions to HTML report templates
Add variables and expressions to your HTML report template as objects. You can use a variable or expression to dynamically store a value or calculation that can be centrally modified and re-used across a report.
Variables
You can insert variables from the app into the template. Like other template objects you create, a variable is added as an object in the template configuration, and is accessible from the objects panel. Add an instance of the variable object as a variable tag.
You can add both scripted variables and variables defined in sheet view.
Do the following:
-
In the HTML designer, place your cursor at the location in the code at which you want to insert the variable.
-
Click
in the objects panel.
Variables and expressions menu in the objects panel within the HTML designer
-
Click Add variable. A list of available app variables appears.
-
Click the
icon to the right of an existing variable to add it.
Select a variable you want to add to the template
-
The variable tag is inserted at your current location in the template code. The settings page for the variable appears. Under Expression, you can view a Preview of the current variable value.
Template design surface with variable added as a tag
-
In the objects panel, provide a unique Name to the variable so you can identify it later.
-
Adjust any other parameters as needed.
-
You can re-use the variable object at any time. Open
in the objects panel, and click
to open the object. Click Add variable tag to add the variable again.
For information on other important actions you need to complete with variables, see the following:
Expressions
Add expressions as objects using the same syntax and functions that are available in analytics apps. Like other template objects you create, an expression is added as an object in the template configuration, and is accessible from the objects panel. Add an instance of the expression object as an expression tag.
Popular expressions you might want to add include:
-
=Count(distinct <your dimension field>): returns the number of unique values for a dimension field you define in the expression (for example, Customer or Product).
-
=today(): returns the current date.
-
=year(now): returns the current year.
Adding an expression
-
In the HTML designer, place your cursor at the location in the code at which you want to insert the table.
-
Click
in the objects panel.
Variables and expressions menu in the objects panel within the HTML designer
-
Click Add expression.
-
Configure the new expression by adding a Name and Description (optional), and then define the Expression.
Define the expression you want to use in the template
-
Check the Preview value under the Expression field to make sure you have configured the expression correctly, and click Create.
-
The expression tag is inserted at your current location in the template code. The settings page for the expression appears. Under Expression, you can view a Preview of the current variable value.
Template design surface with expression added as a tag
-
In the objects panel, provide a unique Name to the variable so you can identify it later.
-
You can re-use the expression object at any time. Open
in the objects panel, and click
to open the object. Click Add expression tag to add the expression again.
For information on other important actions you need to complete with expressions, see the following:
Formatting a variable or expression
Style and format the variable to meet your requirements using HTML code. Possible customizations include font styling, number formatting, and using the variable in natural language in your report. The formatting is applied to the report output.