New MAQL Logarithmic and Exponential Functions
Four new mathematical functions in MAQL will now allow you to use exponents and logarithms while working with metrics, metric expressions, or numerical constants:
- Logarithmic Function: LOG( )
- Natural Logarithmic Function: LN( )
- Exponential Function: EXP( )
- Power (Exponent) Function: POWER( )
LOG( )
Description |
The LOG( n , b ) function returns the logarithm, base b, of n where:
This function takes as arguments any numeric data, including constants, metrics, or metric expressions. If no base is specified, the default base of 10 is applied. |
Syntax |
LOG(…) SQRT(number, base) |
Examples |
SELECT LOG(10, 1/12) SELECT LOG(SUM(Amount), 2) SELECT LOG(Amount[Max]*400, Amount [Max]) |
LN( )
Description |
LN(n) returns the natural logarithm of n, where n is greater than 0. A natural logarithm is the inverse of the EXP( ) function; LN( ) returns the logarithm of a number with base e, the constant 2.71828182845904. LN( ) takes as arguments any numeric data, including metrics, metrics expressions, and constants. |
Syntax |
LN(…) LN(number) |
Examples |
SELECT LN(10) SELECT LN(1/12) SELECT LN(1.5) SELECT LN(SUM(Amount)) |
EXP( )
Description |
The inverse of the LN( ) function, EXP(n) returns the value of the constant e, 2.71828182845904, raised to the power of the positive real number, n, that is specified. EXP( ) takes as arguments any numeric data, including metrics, metrics expressions, and constants. |
Syntax |
EXP(…) EXP(number) |
Examples |
SELECT EXP(10) SELECT EXP(1/12) SELECT EXP(1.5) SELECT EXP(SUM(Amount)) |
POWER( )
Description |
POWER( n , b ) returns n raised to the b power. The base n and the exponent b accept any numeric data, including metrics, metric expressions, and constants. Note: For fractional exponent (b) values, using fractions (e.g. 1/2) rather than decimals (e.g. 0.5) improves performance. |
Syntax |
POWER(…,…) POWER(number , power) |
Examples |
SELECT POWER(10, 1/12) SELECT POWER(SUM(Amount), 2) SELECT POWER(1, Amount) SELECT POWER(Amount * (1/2), Amount) |
For a comprehensive look at how you can write custom metrics in GoodData, see the MAQL Reference Guide.
To learn more about other recently added MAQL functions, see Introducing the Extensible Analytics Engine.
Comments