Graph query language (GQL)
GQL is used to calculate values that are used in the graphs, tables and figures that can be viewed in the model. GQL is used in gqueries, see the section about Writing gqueries for more information.
Graph Query Language (GQL) is case sensitive. Since all GQL functions are written in caps, this means that all functions must be written in caps in order to function.
Functions
Math functions
The math functions consists of functions that perform mathematical operations or calculations on numerical data. Some example functions are COUNT(), SUM(), DIVIDE() can be found here as well as comparing functions like GREATER() or EQUALS().
COUNT(values)
Returns how many values. Removes nil values, but does not remove duplicates.
COUNT(V(foo,bar))
=> 2
Multiple LOOKUPS (does not remove duplicates)
COUNT(V(foo,bar), V(foo))
=> 3
Duplicates in one LOOKUP (does remove duplicates)
COUNT(V(foo,bar,foo))
=> 2
NEG(values)
Returns the first number as a negative.
NEG(2)
=> -2
NEG(1,2,3)
=> -1
AVG(values)
Returns the average of all number (ignores nil values).
AVG(1,2)
=> 1.5
AVG(1,2,3)
=> 2
AVG(1,nil,nil,2)
=> 1.5
SUM
Returns the sum of all numbers (ignores nil values).
SUM(1,2)
=> 3
SUM(1,nil)
=> 1
PRODUCT(values)
Multiplies all numbers (ignores nil values).
PRODUCT(1,2,3)
=>6 (1*2*3)
PRODUCT(1,nil)
=> 1
DIVIDE(values)
Divides the first value with the second value.
DIVIDE(1,2)
=> 0.5
DIVIDE(1,2,3,4)
=> 0.5 --> only takes the second.
MAX(values)
Returns the highest number.
MAX(-3,-2,5)
=> 5
MIN(values)
Returns the lowest number.
MIN(-3,-2,5)
=> - 3
ABS(values)
Returns all given numbers in absolute values.
ABS(-3,-2,5)
=> [3,2,5]
ROUND(value, precision = 0)
Public: Rounds numeric value to a given precision.
ROUND(3.334,2)
=> [3.33]
FLOOR(value, precision = 0)
Returns the largest number less than or equal to numeric value.
FLOOR(3.5)
=> 3
CEIL(value, precision = 0)
Returns the smallest number greater than or equal to numeric value.
CEIL(3.5)
=> 4
SQRT(values)
Returns the square root of the given values.
SQRT(4)
=> [2]
SQRT(4,9)
=> [2,3]
LESS(x,y)
Returns true when x is smaller than y. Note: This function only looks at the first two values entered in this function.
LESS(1,2)
=> true
LESS(2,1)
=> false
LESS(1,2,1)
=> true
LESS(1,2,5)
=> true
LESS_OR_EQUAL(x,y)
Returns true when x is smaller or equal than y. Note: This function only looks at the first two values entered in this function.
LESS_OR_EQUAL(1,2)
=> true
LESS_OR_EQUAL(1,1)
=> true
LESS_OR_EQUAL(2,1)
=> false
LESS_OR_EQUAL(1,2,1)
=> true
LESS_OR_EQUAL(1,2,5)
=> true
GREATER(x,y)
Returns true when x is greater than y. Note: This function only looks at the first two values entered in this function.
GREATER(1,2)
=> false
GREATER(2,1)
=> true
GREATER(2,1,1)
=> true
GREATER(2,1,5)
=> true
GREATER_OR_EQUAL(x,y)
Returns true when x is smaller or equal than y. Note: This function only looks at the first two values entered in this function.
GREATER_OR_EQUAL(1,2)
=> false
GREATER_OR_EQUAL(1,1)
=> true
GREATER_OR_EQUAL(2,1)
=> true
GREATER_OR_EQUAL(2,1,1)
=> true
GREATER_OR_EQUAL(2,1,5)
=> true
EQUALS(x,y)
Returns true when x is equal to y. Note: This function only looks at the first two values entered in this function.
EQUALS(1,1)
=> true
EQUALS(1,2)
=> false
EQUALS(1,1,5)
=> true
NOT
Returns true when x is not equal to y. Note: This function only looks at the first two values entered in this function.
NOT(1,1)
=> false
NOT(1,2)
=> true
NOT(1,1,5)
=> false
OR(values)
Takes any number of arguments and checks if any of the arguments are true. If any are true, the functions returns 'true'. If not, false is returned.
OR(true,false)
=> true --> true is one of the arguments.
OR(false,false)
=> false --> true is not one of the arguments
OR(3,3)
=> false --> true is not one of the arguments
IS_NUMBER(x)
Returns true when x is a number. Note: The value is only recognized when placed in brackets. Furthermore it only looks at the first element inside the brackets. While not using brackets, the function will expect one element.
IS_NUMBER(1)
=> Error
IS_NUMBER([3])
=> true
IS_NUMBER('three')
=> false
IS_NUMBER([3,'three'])
=> true
IS_NUMBER([3],'three')
=> Error: Wrong number of elements
IS_NIL (value)
Returns true when the given value is nil. False when the value is not nil.
NEG(x)
Returns the negative value of the given value. Note: Only the first value is taken into account.
NEG(1)
=> -1
NEG(1,2)
=> -1
NEG(-1,-2)
=> 1
UNIT(x,unit)
Converts a value to another format.
UNIT(0.15,percentage)
=> 15.0 (%)
INVERSE(x)
Returns the inverse of a given value. Note: Only the first value is taken into account.
INVERSE(5)
=> 0.2
INVERSE(5,2)
=> 0.2
FLATTEN(array)
Flattens any nested arrays into a single array with depth=1, removing nils
FLATTEN([[1],[2],[3]])
=>
[1,2,3]
EQUALS(values)
Checks if the first two values that are given are equal.
EQUALS(2,2)
=> true
EQUALS(2,3)
=> false
EQUALS(2,2,3)
=> true
EQUALS(2,3,3)
=> false
IF(condition, true_stmt, false_stmt)
If the condition is true, the true_stmt is returned, if the condition is false, the false_stmt is returned.
IF(EQUALS(1,1),3,4)
=> 3 --> EQUALS(1,1) returns 'true', so 3 is returned.
IF(EQUALS(1,2),3,4)
=> 4 --> EQUALS(1,2) returns 'false', so 4 is returned.