0% found this document useful (0 votes)
5 views

AYX Abacus Manual

Uploaded by

Alberto Guisande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

AYX Abacus Manual

Uploaded by

Alberto Guisande
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

[[MiscUtils|Miscellaneous-Functions-(MiscUtils.

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.

Date Time Creation Functions (Currently Just Concatenation)


• MakeDate: Create a new date from Year, Month, Day
• MakeTime: Create a new time from Hour, Minute, Second
• MakeDateTime: Create a new DateTime from Year, Month, Day, Hour, Minute, Second
• ToDate: Truncate a DateTime to a Date
• ToDateTime: Appends midnight to a Date to create a DateTime
Date Time Parse Functions
• DateFromMDY: Parse a string in Month Day Year format to a Date (copes without
leading 0s and different separators)
• DateFromDMY: Parse a string in Day Month Year format to a Date (copes without
leading 0s and different separators)

Date Part Functions (returns numbers)


• Day: Get the day of the Month [1-31]
• Month: Gets the month number [1-12]
• Year: Gets the four digit year
• WeekDay: Gets the day of the week [Sunday (0) through to Saturday (6)]
• Quarter: Gets the quarter of the date [1-4]
• OrdinalDay: Gets the day of the year [1-366]

Period Start and End


• WeekStart: Gets the first Sunday before or equal to date
• WeekEnd: Gets the first Saturday after or equal to date
• MonthStart: Gets the first day of the month containing the date
• MonthEnd: Gets the last day of month containing the date
• QuarterStart: Gets the first day of the quarter containing the date
• QuarterEnd: Gets the last day of the quarter containing the date
• YearStart: Gets the first day of the year containing the date
• YearEnd: Gets the last day of the year containing the date

Other Date Functions


• DateAdd: Equivalent to DateTimeAdd: Number of weekdays between two dates
• IsLeapYear: Is a year a leap year (takes a year not a date as an input use
IsLearYear(Year([Date]))

[[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

Truncates a DateTime value to a Date


• Only sanity checking is on the length of the field past. If not 10 (a Date) or 19 (a
DateTime), returns NULL.

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

Appends Midnight to a Date to create a DateTime value


• Only sanity checking is on the length of the field past. If not 10 (a Date) or 19 (a
DateTime), returns NULL.

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

Returns the day of the month as a number (1 - 31).

Month
Syntax: MONTH(DateTime)
Examples:
• MONTH('2010-12-31') returns 12
• MONTH('2010-12-31 11:22:33') returns 12

Returns the month as a number (1 - 12).

Year
Syntax: YEAR(DateTime)
Examples:
• YEAR('2010-12-31') returns 2010
• YEAR('2010-12-31 11:22:33') returns 2010

Returns the four digit year as number.

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

Returns the quarter of the date as a number (1 - 4).

OrdinalDay
Syntax: ORDINALDAY(DateTime)
Examples:
• ORDINALDAY('2010-12-31') returns 31
• ORDINALDAY('2010-12-31 11:22:33') returns 31

Returns the day of the year as a number (1 - 366).

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

Returns the nearest Sunday less than or equal to DateTime.

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

Returns the nearest Saturday greater than or equal to DateTime.

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

Returns the last day of the month of DateTime.

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

Returns the first day of the quarter of DateTime.

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

Returns the last day of the quarter of DateTime.

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

Returns the first day of the year of DateTime.


YearEnd
Syntax: YEAREND(DateTime)
Examples:
• YEAREND('2010-12-31') returns 2010-12-31
• YEAREND('2010-12-31 11:22:33') returns 2010-12-31
• YEAREND('2012-01-01') returns 2012-12-31

Returns the last day of the year of DateTime.

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'

Equivalent to [DateTimeAdd](## BusinessDays ##


Syntax: BUSINESSDAYS(StartDate, EndDate)
Examples:
• BUSINESSDAYS('2016-05-06','2016-05-13') returns 6
• BUSINESSDAYS('2016-05-07','2016-05-13') returns 5
• BUSINESSDAYS('2016-05-13','2016-05-13') returns 1
• BUSINESSDAYS('2016-05-14','2016-05-14') returns 0

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

Is a year a leap year.


• Function takes a year not a date as an input, use IsLearYear(Year([Date]) for a Date
input.
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](## 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 result will be NULL.

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.

• If P is less than 0 or greater than 1, returns NULL.


• Use the Rand() function to generate a random value of P.

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

Computes the average (mean) of a set inputs ignoring NULL values.


• All parameters must be a 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.
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`

Counts the number of values which are not NULL.


• Can be any combination of numeric or text types.
• 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.
• SUM(1, 2) returns 3
• SUM(1, NULL) returns 1
• SUM(NULL, 2) returns 2
• SUM(1, 2, 3) returns 6

Computes the total of a set inputs ignoring NULL values.


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

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

Converts from degrees to radians.

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

If the first parameter is NULL, returns the second parameter.


• If both Value and ValueIfNull are NULL, returns NULL.

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!

Allows you report an error from a function or pass through a value.


This provides a few extension methods for working with strings.
All functions treat strings as Unicode so can used with all the string types.
As Alteryx represents Dates, Times and DateTimes as strings they can also be used on those
types.
All functions will be added to the String category in the function list.
**Unit tests for all these functions in [StringUtils.Test](## LeftPart ##
Syntax: LEFTPART(Text, Delimiter)
Examples:
• LEFTPART('Hello World', ' ') returns 'Hello'
• LEFTPART('Hello', ' ') returns 'Hello'
• LEFTPART('This is some text', ' is ') returns 'This'

Gets the part of Text before the Delimiter.


• The Delimiter can be longer than a single character.
• If Text is NULL, then the function will return NULL.
• If Delimiter is NULL or an empty string, then the Text value will be returned.
• If Delimiter is not found within the Text, then the result will be the Text value.

RightPart
Syntax: RIGHTPART(Text, Delimiter)
Examples:
• RIGHTPART('Hello World', ' ') returns 'World'
• RIGHTPART('Hello', ' ') returns 'Hello'
• RIGHTPART('This is some text', ' is ') returns 'some text'

Gets the part of Text after the Delimiter.


• The Delimiter can be longer than a single character.
• If Text is NULL, then the function will return NULL.
• If Delimiter is NULL or an empty string, then the Text value will be returned.
• If Delimiter is not found within the Text, then the result will be the Text value.
Split
C++ Function - Split
Syntax: `SPLIT(Text, Delimiter, Index)'
Examples:
• SPLIT('Hello World', ' ', 1) returns 'Hello'
• SPLIT('Hello', ' ', 1) returns 'Hello'
• SPLIT('Hello World', ' ', 3) returns NULL

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

Returns TRUE if Target is contained in Text.


• If both Text and Target are NULL, returns true.
• If Text is NULL and Target is not, then the function will return false.
• If Target is NULL or an empty string, and Text is not, returns true.

StartsWith
Syntax: STARTSWITH(Text, Target)
Examples:
• STARTSWITH('Hello World', 'Hello') returns TRUE
• STARTSWITH('Hello World', 'World') returns FALSE

Returns TRUE if Text starts with Target.


• If both Text and Target are NULL, returns true.
• If Text is NULL and Target is not, then the function will return false.
• If Target is NULL or an empty string, and Text is not, returns true.

EndsWith
Syntax: ENDSWITH(Text, Target)
Examples:
• ENDSWITH('Hello World', 'World') returns TRUE
• ENDSWITH('Hello World', 'Hello') returns FALSE

Returns TRUE if Text ends with Target.


• If both Text and Target are NULL, returns true.
• If Text is NULL and Target is not, then the function will return false.
• If Target is NULL or an empty string, and Text is not, returns true.

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!

You might also like