AYX Abacus Manual
AYX Abacus Manual
xml)]]
A few additional general methods for data preparation.
• IfNull: If first value is null return second
• Coalesce: Given list of values return first non null value
[[MathUtils|Math-Functions-(MathUtils.xml)]]
Math based functions that I havent got a better home for!
• Modulo: General Double Based Modulo function
• HexBinX: Given an X, Y point and optional radius, get X coordinate of hexagonal bin's
center
• HexBinY: Given an X, Y point and optional radius, get Y coordinate of hexagonal bin's
center
• Rand_Triangular: Given a uniform random number transform into a triangular
distributed random
• Avg: Average of a list of values ignoring NULL
• Count: Count of a list of values ignoring NULL
• Sum: Sum of a list of values ignoring NULL
• Deg: Convert radians to degrees
• Rad: Convert degrees to radians
• NormDist: Compute PDF or CDF on Normal distribution
• NormInv: Compute inverse CDF on Normal distribution
• LogNormDist: Compute PDF or CDF on Log Normal distribution
• LogNormInv: Compute inverse CDF on Log Normal distribution
• TDist: Compute two-tailed probability on a Student T distribution
• TInv: Compute inverse CDF on Normal distribution
• ChiDist: Compute PDF or CDF on Log Normal distribution
• ChiInv: Compute inverse CDF on Log Normal distribution
[[DateUtils|Date-and-Time-Functions-(DateUtils.xml)]]
Some additional functions for working with Dates and to a certain extent Times.
[[StringUtils|String-Functions-(StringUtils.xml)]]
A few extension methods for working with strings.
• LeftPart: Gets the text before the first instance of a separator
• RightPart: Gets the text after the first instance of a separator
• Split: Splits a string into tokens and then returns the specified instance
Retired Functions
• StartsWith: Does a string start with another
• EndsWith: Does a string end with another
• Contains: Is a string in another
This provides some additional functions for working with Dates and to a certain extent
Times.
Unless specified, the functions listed below will be added to a new Date category.
**Unit tests for all these functions in [DateUtils.Test](## MakeDate ##
C++ Function - MakeDate
Syntax: MAKEDATE(Year, Month, Day)
Defaults: Month = 1, Day = 1
Examples:
• MAKEDATE(2010, 1, 2) returns '2010-01-02'
Creates a date from numerical inputs of Year, Month and Day. Month and Day are optional
inputs defaulting to 1.
• As of version 1.3, this checks the validity of the inputs and will warn if invalid. Please note
that 0, 0, 0 is a valid input (i.e. no warning message) returning NULL.
MakeTime
C++ Function - MakeTime
Added to Time category
Syntax: MAKETIME(Hour, Minute, Second)
Defaults: Hour = 0, Minute = 0, Second = 0
Examples:
• MAKETIME(12, 34, 56) returns '12:34:56'
Creates a time from numerical inputs of Hour, Minute and Second. All arguments are
optional, defaulting to 0.
• As of version 1.3, this checks the validity of the inputs and will warn if invalid.
MakeDateTime
C++ Function - MakeDateTime
Added to DateTime category
Syntax: MAKEDATETIME(Year, Month, Day, Hour, Minute, Second)
Defaults: Month = 1, Day = 1, Hour = 0, Minute = 0, Second = 0
Examples:
• MAKEDATETIME(2010, 1, 2, 12, 34, 56) returns '2010-01-02 12:34:56'
Creates a date and time from numerical inputs of Year, Month, Day, Hour, Minute and
Second. All arguments except Year ae optional.
• As of version 1.3, this checks the validity of the inputs and will warn if invalid.
ToDate
Syntax: TODATE(DateTime)
Examples:
• TODATE('2010-12-31') returns 2010-12-31
• TODATE('2010-12-31 11:22:33') returns 2010-12-31
ToDateTime
Syntax: TODATETIME(Date)
Examples:
• TODATETIME('2010-12-31') returns 2010-12-31 00:00:00
• TODATETIME('2010-12-31 11:22:33') returns 2010-12-31 11:22:33
DateFromMDY
Syntax: DATEFROMMDY(MDYString)
Examples:
• DATEFROMMDY('7/2/17') returns 2017-02-07
Parse a string in Month Day Year format to a Date (copes without leading 0s and different
separators)
DateFromDMY
Syntax: DATEFROMDMY(DMYString)
Examples:
• DATEFROMDMY('7/2/17') returns 2017-07-02
Parse a string in Day Month Year format to a Date (copes without leading 0s and different
separators)
Day
Syntax: DAY(DateTime)
Examples:
• DAY('2010-12-31') returns 31
• DAY('2010-12-31 11:22:33') returns 31
Month
Syntax: MONTH(DateTime)
Examples:
• MONTH('2010-12-31') returns 12
• MONTH('2010-12-31 11:22:33') returns 12
Year
Syntax: YEAR(DateTime)
Examples:
• YEAR('2010-12-31') returns 2010
• YEAR('2010-12-31 11:22:33') returns 2010
WeekDay
Syntax: WEEKDAY(DateTime)
Examples:
• WEEKDAY('2010-12-31') returns 5 (Friday)
• WEEKDAY('2010-12-31 11:22:33') returns 5 (Friday)
• WEEKDAY('2012-01-01') returns 0 (Sunday)
Returns the day of the week represented as a number: 0 - Sunday through to 6 - Saturday.
Quarter
Syntax: QUARTER(DateTime)
Examples:
• QUARTER('2010-12-31') returns 4
• QUARTER('2010-12-31 11:22:33') returns 4
• QUARTER('2010-01-31') returns 1
OrdinalDay
Syntax: ORDINALDAY(DateTime)
Examples:
• ORDINALDAY('2010-12-31') returns 31
• ORDINALDAY('2010-12-31 11:22:33') returns 31
WeekStart
Syntax: WEEKSTART(DateTime)
Examples:
• WEEKSTART('2010-12-31') returns 2010-12-26
• WEEKSTART('2010-12-31 11:22:33') returns 2010-12-26
• WEEKSTART('2012-01-01') returns 2012-01-01
WeekEnd
Syntax: WEEKEND(DateTime)
Examples:
• WEEKEND('2010-12-31') returns 2011-01-01
• WEEKEND('2010-12-31 11:22:33') returns 2011-01-01
• WEEKEND('2012-01-01') returns 2012-01-07
MonthStart
Syntax: MONTHSTART(DateTime)
Examples:
• MONTHSTART('2010-12-31') returns 2010-12-01
• MONTHSTART('2010-12-31 11:22:33') returns 2010-12-01
• MONTHSTART('2012-01-01') returns 2012-01-01
Returns the first day of the month of DateTime.
MonthEnd
Syntax: MONTHEND(DateTime)
Examples:
• MONTHEND('2010-12-31') returns 2010-12-01
• MONTHEND('2010-12-31 11:22:33') returns 2010-12-01
• MONTHEND('2012-01-01') returns 2012-01-01
QuarterStart
Syntax: QUARTERSTART(DateTime)
Examples:
• QUARTERSTART('2010-12-31') returns 2010-01-01
• QUARTERSTART('2010-12-31 11:22:33') returns 2010-01-01
• QUARTERSTART('2012-01-01') returns 2012-01-01
QuarterEnd
Syntax: QUARTEREND(DateTime)
Examples:
• QUARTEREND('2010-12-31') returns 2010-12-31
• QUARTEREND('2010-12-31 11:22:33') returns 2010-12-31
• QUARTEREND('2012-01-01') returns 2012-12-31
YearStart
Syntax: YEARSTART(DateTime)
Examples:
• YEARSTART('2010-12-31') returns 2010-01-01
• YEARSTART('2010-12-31 11:22:33') returns 2010-01-01
• YEARSTART('2012-01-01') returns 2012-01-01
DateAdd
Syntax: DATEADD(Date, Interval, Units)
Examples:
• DATEADD('2010-12-31', 1, 'days') returns '2011-01-31'
• DATEADD('2010-12-31 11:22:33', 1, 'days') returns '2011-01-31'
Number of weekdays (Monday - Friday) between two dates including both start and end.
• If StartDate is after EndDate, returns NULL.
IsLeapYear
Syntax: ISLEAPYEAR(Year)
Examples:
• ISLEAPYEAR(2016) returns TRUE
• ISLEAPYEAR(2010) returns FALSE
• ISLEAPYEAR(1900) returns FALSE
• ISLEAPYEAR(2000) returns TRUE
HEXBINX
Added to Spatial category
C++ Function - HexBinX
Syntax: HEXBINX(PointX, PointY, Radius)
Examples:
• HEXBINX(0, 0) returns 0
• HEXBINX(1, 1) returns 1.5
• HEXBINX(1, 1, 2) returns 0
Given a point (X, Y), returns the X co-ordinate of 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 but rotated by 90 degrees.
• If PointX or PointY is NULL, returns NULL.
• If Radius is NULL, uses 1.
HEXBINY
Added to Spatial category
C++ Function - HexBinY
Syntax: HEXBINY(PointX, PointY, Radius)
Examples:
• HEXBINY(0, 0) returns 0
• HEXBINY(1, 1) returns 0.866025
• HEXBINY(1, 1, 2) returns 0
Given a point (X, Y), returns the Y co-ordinate of 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 HEXBINY function.
• Based on the d3.js implementation but rotated by 90 degrees.
• If PointX or PointY is NULL, returns NULL.
• If Radius is NULL, uses 1.
RAND_TRIANGULAR
Syntax: RAND_TRIANGULAR(P, Min, Mode, Max)
Examples:
• RAND_TRIANGULAR(0, 0, 1, 2) returns 0
• RAND_TRIANGULAR(1, 0, 1, 2) returns 2
• RAND_TRIANGULAR(0.5, 0, 1, 2) returns 1
Given a probability, P, convert into the value on a Triagular distribution with range (Min,
Max) and mode equal to Mode.
AVG
C++ Function - Average
Syntax: AVG(Value1, Value2, ...) Takes variable number of parameters.
Examples:
• AVG(1, 2) returns 1.5
• AVG(1, NULL) returns 1
• AVG(NULL, 2) returns 2
• AVG(1, 2, 3) returns 2
COUNT
C++ Function - Count
Syntax: COUNT(Value1, Value2, ...) Takes variable number of parameters.
Examples:
• COUNT(1, 2) returns 2
• COUNT(1, NULL) returns 1
• COUNT(NULL, 2) returns 1
• COUNT(1, 2, 3) returns 3
• COUNT('A', NULL, 1, 'B') *returns* 3`
SUM
C++ Function - Sum
Syntax: SUM(Value1, Value2, ...) Takes variable number of parameters.
• SUM(1, 2) returns 3
• SUM(1, NULL) returns 1
• SUM(NULL, 2) returns 2
• SUM(1, 2, 3) returns 6
DEG
Syntax: DEG(radians)
• DEG(0) returns 0
• DEG(1) returns 57.29577951
• DEG(NULL()) returns NULL
Converts from radians to degrees.
RAD
Syntax: RAD(degrees)
• RAD(0) returns 0
• RAD(57.29577951) returns 1
• RAD(NULL()) returns NULL
NORMDIST
C++ Function - NormDist
Syntax: NORMDIST(X, Mean, StDev, Cumulative)
Defaults: Mean = 0, StDev = 1, Cumulative = false
Computes either probability mass function or cumulative distribution function value of x
on a Normal distribution with specified Mean and Standard Deviation.
NORMINV
C++ Function - NormInv
Syntax: NORMINV(P, Mean, StDev)
Defaults: Mean = 0, StDev = 1
Computes the inverse of cumulative distribution function value for a specified value of P on
a Normal distribution with specified Mean and Standard Deviation.
LOGNORMDIST
C++ Function - LogNormDist
Syntax: LOGNORMDIST(X, Mean, StDev, Cumulative)
Defaults: Mean = 0, StDev = 1, Cumulative = false
Computes either probability mass function or cumulative distribution function value of x
on a Log Normal distribution with specified Location and Scale.
LOGNORMINV
C++ Function - LogNormInv
Syntax: LOGNORMINV(P, Mean, StDev)
Defaults: Mean = 0, StDev = 1
Computes the inverse of cumulative distribution function value for a specified value of P on
a Log Normal distribution with specified Location and Scale.
TDIST
C++ Function - TDist
Syntax: TDIST(X, DegreesOfFreedom)
Computes the two-tailed probability on a student T distribution with specified degrees of
freedon for a value of x.
TINV
C++ Function - TInv
Syntax: TINV(P, DegreesOfFreedom)
Computes the inverse of cumulative distribution function value for a specified value of P on
the two tailed student T distribution with specified degrees of freedom.
CHIDIST
C++ Function - ChiDist
Syntax: CHIDIST(X, DegreesOfFreedom)
Computes the right-tailed probability on a Chi-Squared distribution with specified degrees
of freedon for a value of x.
CHIINV
C++ Function - ChiInv
Syntax: CHIINV(P, DegreesOfFreedom)
Computes the inverse of the right-tailed probability for a specified value of P on the Chi-
Squared distribution with specified degrees of freedom.
This provides a few additional general methods for data preparation.
Each function listed below states the category it is added to.
**Unit tests for all these functions in [MiscUtils.Test](## Version ##
Added to Specialized category
Syntax: VERSION()
Examples:
• Version() returns 11.0 (assuming running in 11.0!)
• Version(3, ) returns the Build and Revision number
Gets the Major and Minor version numbers of the Engine as a number. Other parts of the
version can be specified by passing arguments to the function.
IfNull
Added to Specialized category
Syntax: IFNULL(Value, ValueIfNull)
Examples:
• IFNULL('A', 'B') returns A
• IFNULL(NULL, 'B') returns B
Coalesce
Added to Specialized category
C++ Function - Coalesce
Syntax: COALESCE(Value1, Value2, ...) Takes variable number of parameters.
Examples:
• COALESCE('A', 'B') returns A
• COALESCE(NULL, 'B') returns B
• COALESCE(NULL, NULL< 'C') returns C
Generalised version of IfNull, returns the first parameter which is not NULL.
• 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.
ReportError
Added to Specialized category
Syntax: ReportError(Condition, Message, ReturnValue)
Defaults: Condition = True, Message = "Reporting An Error!", ReturnValue = NULL
Examples:
• ReportError() returns an error of Reporting An Error!
• ReportError(0) returns NULL
• ReportError(1, 'An Error') returns an error of An Error
• ReportError(0, 'An Error', 3) returns 3
• ReportError(0, 'An Error', 'All Ok!') returns All Ok!
RightPart
Syntax: RIGHTPART(Text, Delimiter)
Examples:
• RIGHTPART('Hello World', ' ') returns 'World'
• RIGHTPART('Hello', ' ') returns 'Hello'
• RIGHTPART('This is some text', ' is ') returns 'some text'
Splits Text into an array and then returns the specified index (first element is index 1)
• If the delimiter is more than one character, then each character is used as a delimiter.
• There is no support for " blocks containing delimiters.
• Repeated delimiters will result in an empty string value in the array.
• If the index is greater than the array length, then the result is NULL.
• If Text is NULL, then the function will return NULL.
Deprecated Functions
The following functions have been added to Alteryx in version 10.
They are still contained within the [StringUtils.xml](## Contains ##
Syntax: CONTAINS(Text, Target)
Examples:
• CONTAINS('Hello World', ' ') returns TRUE
• CONTAINS('Hello World', ',') returns FALSE
StartsWith
Syntax: STARTSWITH(Text, Target)
Examples:
• STARTSWITH('Hello World', 'Hello') returns TRUE
• STARTSWITH('Hello World', 'World') returns FALSE
EndsWith
Syntax: ENDSWITH(Text, Target)
Examples:
• ENDSWITH('Hello World', 'World') returns TRUE
• ENDSWITH('Hello World', 'Hello') returns FALSE
ToRoman
Syntax: TOROMAN(Value)
Examples:
• TOROMAN(10) returns X
Returns the Roman Numeral representation of a number. Valid inputs from 1 to 5000.
FromRoman
Syntax: FROMROMAN(RomanNumerals)
Examples:
• TOROMAN('X') returns 10
Returns numeric value of a the Roman Numeral. Only tested to 5000, but should cope with
a longer list of Ms!