This Evaluate functions (since version 10.1.3.3) enables users and administrators to create more powerful reports by directly calling Database functions from:
The following new BI Server database functions are supported
Functions | For |
---|---|
EVALUATE | scalar function that are computed post-aggregation and analytic calculations |
EVALUATE_AGGR | aggregate functions with group by clause |
EVALUATE_PREDICATE | functions with a return type of boolean |
This feature is restricted to support SQL sources. MDX or MOLAP data sources are not supported with an exception for Essbase.
The EVALUATE function is not enabled by default because it exposes the database to SQL injection attacks.
If you encounter any error, see if you must set the value of the EVALUATE_SUPPORT_LEVEL parameter in the NQSConfig.INI file.
EVALUATE_SUPPORT_LEVEL = 0;
See Documentation
The escape character is the quote.
Example: The regular expressions of oracle contain the pattern expression in quote (in the code below '^[A-Z]+').
To prevent a syntax error, you must add a quote before your quotes such as:
EVALUATE('REGEXP_SUBSTR(%1,''^[A-Z]+'')', MyTable.MyColumn)
If you don't do it, you can get this error:
[nQSError: 27002] Near <^>: Syntax error [nQSError: 26012] .
This function is intended for scalar calculations.
Syntax:
EVALUATE('DB_Function(%1)' [as datatype], <Comma separated Expression of Parameters>)
where:
Example:
SELECT e.lastname,sales.revenue,EVALUATE('dense_rank() over(order by %1 )' as double,sales.revenue) FROM sales s, employee e;
This function is intended for aggregate functions.
Syntax:
EVALUATE_AGGR('DB_Aggregate_Function(%1)', <comma separated Expression)
Example with the Listagg function in a logical SQL (WM_CONCAT works also) :
SELECT order.nummer, sales.qtysold, EVALUATE_AGGR('listagg(%1)', sales.item) From SnowFlakeSales;
This function is intended for functions with a return type of boolean.
Syntax:
EVALUATE_PREDICATE('DB_Function(%1)', <comma separated Expression)
Example:
SELECT year, Sales as DOUBLE,CAST(EVALUATE('OLAP_EXPRESSION(%1,''LAG(units_cube_sales, 1, time,
time LEVELREL time_levelrel)'')', OLAP_CALC) AS DOUBLE)
FROM "Global".Time, "Global"."Facts - sales"
WHERE EVALUATE_PREDICATE('OLAP_CONDITION(%1, ''LIMIT time KEEP ''''1'''', ''''2'''', ''''3'''', ''''4'''' '') =1', OLAP_CALC)
order by year;
Odbc driver returned an error (SQLExecDirectW).
Error Details
Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
State: HY000. Code: 2057371920. [NQODBC] [SQL_STATE: HY000]
[nQSError: 10058] A general error has occurred.
[nQSError: 42015] Cannot function ship the following expression: Evaluate(....
This error comes from the fact that OBI is unable to know wich aggregation rule it must apply when you ask for a total in a view. You have to define the answer aggregation rule in the column formula of in the view to resolve this error.
The below error
Message returned from OBIS.
[nQSError: 43119] Query Failed:
[nQSError: 46035] Datatype(INTEGER) nullable(1) unicode(1) external char(0) conversion to datatype(DATE) nullable(1) unicode(0) external char(0) is not supported. (HY000)
occurs when the function pushed return another datatype than the passed parameters.
Example: in the below function, we are passing two date and we are retrieving a number:
EVALUATE( 'DAYS_BETWEEN(%1,%2)' ,"Dim"."Day1", "Dim"."Day2" )
To correct it, you need to define the returned data type of the function (in our case, double)
EVALUATE( 'DAYS_BETWEEN(%1,%2)' as double, "Dim"."Day1", "Dim"."Day2" )