Skip to main content
Formula in Query

Write custom formulas in Query

Updated over 5 months ago

Supported Operators

Supported operators will be +, -, /, *

  • + addition

    • A + B

  • - subtraction

    • A - B

  • / division

    • A / B

  • * multiplication

    • A * B

Supported Functions

  • min(A, B) - returns the min value from both measures

  • max(A, B) - returns the max value from both measures

  • ifnull(A, <default>) - returns A if not null, otherwise the default value

  • sum(A, B, C) - shortcut for sum of multiple measures

  • ceil(A, <scale>) - returns values from A rounded to the nearest equal or larger integer, or to the nearest equal or larger value with the specified number of places after the decimal point

  • round(A, <scale>) - Returns rounded values for A

  • floor(A, <scale>) - returns values from A rounded to the nearest equal or smaller integer, or to the nearest equal or smaller value with the specified number of places after the decimal point

  • pow(A, x) - returns measure value raised to the specified power (x)

  • sqrt(A) - square root of A

  • log(<base>, A) - returns the logarithm of a number given a base

    • The base should be positive number and not equal to 1

Example Formulas

  • min(A,B)/C - is the minimum value between measure A and B, divided by measure C

  • pow(A, 2) - A raised to the power of 2

  • ifnull(A, 1.5) - if A is NULL, then return 1.5

  • ceil, round, floor are utilities for formatting the result measure; round(A, 3) - round A rounds A to a 3rd number of decimal places

  • sum(A,B,C) is a shortcut for A+B+C

  • ceil(min(A,ifnull(B,3.1)),5) - functions can be nested; round the result to 5th number of decimal places, where the result is the min value between A and B (where if B is NULL, then it will be 3.1)

  • log(10, A) - find the logarithm of A with base 10

Did this answer your question?