Using filter macros with SQL queries
Filter macros are pieces of code that are replaced at execution time to produce dynamic results. They are replaced in the SQL query according to the parameters that come from the Dashboard.
The different types of filter macros that can be used in the SQL code of a View template are:
- Simple filter macros: Enables you to specify the name of the parameter and the column (optional) that should be used for filtering.
- Custom filter macros: Enables you to customize the filtering condition.
Additional template macros include:
- Time filter macros: Lets you add time filtering.
- Domain filter macros: Lets you add domain filtering.
- ACL filter macros: Lets you add filtering for entities belonging to domains that a user can exist.
- View macros: Lets you include the SQL code of a data mart within another data mart.
- (Deprecated) View template macros: Lets you include the SQL code of a View template within another View template.
Simple filter macros
Simple filter macros let you insert dynamic content in most SQL queries. Their generic format is:
The macro is substituted in the following way:
Or, if the optional parameter <column-name> is specified, the macro is substituted as:
Custom filter macros
Custom filter macros allow you to apply dynamic changes using a customized where condition. Their generic format is:
The macro is substituted in the following way:
Dashboard parameters
The following table lists all Dashboard parameters that can be used with filter macros:
Dashboard parameters
For custom parameters, the parameter ID is simply the parameter name. For example, if you defined a custom filter named MY_CUSTOM_FILTER and you want to filter on a column named MY_COLUMN, you can use the following macro:
Time filter macros
Time filter macros allow you to add time filtering on the date column. Their generic format is:
Domain filter macros
ACL filter macros
View macros
View macros allow you to include the SQL code of a data mart inside another data mart. Their generic format is:
where <identifier> is the data mart identifier to include and <table-alias> is the alias to be used for the data mart template.
View template macros
View template macros allow you to include the SQL code of a View template inside another View template. Their generic format is:
where <erid> is the View template ID to include and <table-alias> is the alias to be used for the data mart template.