A report variables option can be used to add custom variables to the report. It’s value can be a static text or an expression. You can create report variables when a report design demands a value or calculation to be used many times. Each variable name must be unique in a report.
At run time, the value of report variables is calculated once and is maintained until the report is processed again. You can set a report variable type to be Read-only or Read-write. By default, it is set to Read-only type.
Read-only - Use this type to set constant value for the variable. For example, to create a time stamp. Use the following syntax to call a report variable anywhere in the report, =Variables!MyVariable.Value
Read-write - Use this type to assign value dynamically to the variable at run time. When you set the type to read-write, the Writable property for that specific variable is set to true. Use the following syntax to set value for a report variable, =Variables!MyVariable.SetValue(“test”).
For example, we may want to add report printing time in each page of the report, but using direct expression in a text box will print different time in each page. To get round this problem, we can create a report variable to hold the same time in each page. To create a report variable follow the below steps,
Note: A name should start with an alphabet character and it should not contain spaces and special characters except underscore.
Finally, click on the Update button in the variable panel to save the report variables state.
You can edit the variable name and value anytime in the report. Open the variables panel and edit the required variables, then click on the update button.
To delete the variable from the report, click on the delete icon present on the right side of each variable field and update.
You can call the report variable in any expression. The report variables available in the report are listed under Data dropdown in Expression Builder.
Double click on the variable name to insert them into the text editor and click OK.