Skip to content

Math Functions (MathUtils.xml)

James Dunkerley edited this page May 13, 2016 · 13 revisions

This provides some additional math functions.

Unless specified, the functions listed below will be added to the Math category.

Unit tests for all these functions in MathUtils.Test folder.

Modulo

Syntax: MODULO(Number, Divisor)

Examples:

  • MODULO(1, 2) returns 1
  • MODULO(2.25, 1.5) returns 0.75

Version of the MOD function allowing for floating point numbers.

  • If either Modulo or Divisor are NULL, returns NULL.
  • If Divisor is 0, then will result in an error.

HEXBINX

Added to Spatial category

C++ Function - HexBinX

Syntax: HEXBINX(PointX, PointY, Radius)

Examples:

  • HEXBINX('A', 'B') returns A
  • COALESCE(NULL, 'B') returns B
  • COALESCE(NULL, NULL< 'C') returns C

Given a point X, Y, returns the center of hexagonal bin containing the point. An optional third parameter, allows the size of the Hexagon to be changed (defaults to 1). Reproduces Tableau HEXBINX function, based on the d3.js implementation.

  • All parameters must be same general type (numeric vs text (including dates/datetimes as text)).
  • Minimum of 2 parameters, but can be as many as you need.
  • If all parameters are null, returns NULL.

HEXBINY

Added to Spatial category

C++ Function - HexBinY

RAND_TRIANGULAR

AVG

C++ Function - Average

Syntax: AVG(Value1, Value2, ...) Takes variable number of parameters.

  • All parameters must be numeric type.
  • Minimum of 2 parameters, but can be as many as you need.
  • If all parameters are null, returns NULL.

COUNT

C++ Function - Count

Syntax: COUNT(Value1, Value2, ...) Takes variable number of parameters.

  • Minimum of 2 parameters, but can be as many as you need.
  • If all parameters are null, returns 0.

SUM

C++ Function - Sum

Syntax: SUM(Value1, Value2, ...) Takes variable number of parameters.

  • All parameters must be numeric type
  • Minimum of 2 parameters, but can be as many as you need.
  • If all parameters are null, returns 0.