You can add parameter filters to a report to make it more interactive. Use a parameter filter to show records with the same parameter value. To add parameter filters on a report, you must insert a prompt in the SQL query you use to create the report.
Add a parameter prompt for each parameter you want to filter on. For example, you want to create a report based on employee details that includes the manager and department ID. You want to give users the flexibility to display a list of employees reporting to any given manager or department. To add filters for manager and department IDs, you must use placeholder parameters in the SQL query for both the manager and department ID variables.
The placeholder parameter must be in the following format:
@P_<DataType>_<Prompt>
<DataType>
Specify a datatype. Use one of the following values:
Integer
Number
String
Decimal
If you do not specify a datatype, the parameter will be assigned the default datatype, string.
Date, time, and datetime data types must be converted to string datatypes in the SQL query. Convert data with a date, time, or datetime datatype to a string datatype in one of the following ways:
Use the format
@P_<Prompt>
where the
<DataType>
value is not specified. The parameter values will be treated as string by default.
Add the
char()>
function to convert the parameter to string. The complete format is:
char(<column name>)>@P_<DataType>_<Prompt>
<Prompt>
Represents the label for the parameter filter. Do not use spaces or special characters in the
<Prompt>
value.
Example
The SQL query to add parameter filters for manager and department IDs has the following format:
select * from employees where manager_id =@P_Integer_MgrId and Department_id =@P_Integer_DeptId
When you run a report, you can choose to filter data by manager ID and department ID. The following image shows the filter lists for
MgrId
and
DeptId
:
.
The report displays details of employees associated with the manager and department you selected.