Referencing Parameters in a Formula
A formula which references parameters will return values according to the parameter values. To reference a parameter in a formula, follow the syntax: @ParameterName.
In the following example, a formula will be used to display the URL for a company, which is based on the value of the parameter p_Company.
- Open the catalog file SampleReports.cat in
<install_root>\Demo\Reports\SampleReports
. - In the Catalog Manager, expand the desired data source and create a type-in parameter named p_Company of String type (leave the other settings to their default).
- In the same data source, create a formula named CompanyURL in the Formula Editor as follows:
"http://www." + @p_Company + ".com"
Here, you can either manually type @p_Company, or you can select it from the Parameters node in the Fields panel (if you choose this option, the @ sign will be automatically inserted).
- Insert the formula into a report.
- View the report result, and type the string Jinfonet when prompted to enter the parameter value for p_Company. You will then find that the value of the formula becomes http://www.jinfonet.com.
There may be times you need to display the value of a multi-valued parameter. The built-in function join assists with that. For example, the following expression will show a list of selected states separated by commas:
"Selected States : " + trim(join (@pStates,",")) + "\r\n"
These are simple examples of referencing parameters in formulas, in which the formulas are placed directly into a report. You would better understand the benefits of referencing parameters in formulas which are used to control object properties.