|Declared Functions||(icCube MDX extension)|
Declaration of functions written in MDX.
icCube allows for declaring a function within the scope of a SELECT query. The syntax is very much similar to the declaration of a calculated member.
WITH FUNCTION fun(a,b) AS a + b
The parameter declaration supports some sort of type declaration. Currently the 'Value' type is supported.
WITH FUNCTION fun( Value val ) AS ....
means that the 'val' parameter will be converted to a value before being used within the function. When calling the function with a tuple ' t ', this is equivalent to ' fun( t.value ) '. Declaring a parameter as a 'Value' is simplifying the call of the method and ensure that the value is computed once only. E.g.:
WITH FUNCTION square( Value val ) AS val * val
Note that a function can be passed as a function parameter.
A function can be declared as const using the CONST keyword. In that case, the evaluation of the function is considered as a constant and is evaluated once outside the current context except for the slicer and the sub-select. Several limitations apply to const functions as described in the following examples.
WITH CONST FUNCTION fun() AS ...
WITH FUNCTION CONST fun() AS ...
Similarly, functions can be declared (and removed) at schema level using the CREATE / DROP statements.
DROP FUNCTION fun
CREATE FUNCTION fun(a,b) AS a+b
The following examples are demonstrating several features of these function declarations.
Find here the value of the XMLA properties when not specified otherwise.