0% found this document useful (0 votes)
373 views963 pages

Power Query M Functions Overview

This handbook would give you a deep dive on the M language framework which is the code that power query was built on.

Uploaded by

Scribd-Online
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)
373 views963 pages

Power Query M Functions Overview

This handbook would give you a deep dive on the M language framework which is the code that power query was built on.

Uploaded by

Scribd-Online
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

Contents

Power Query M formula language


Quick tour of the Power Query M formula language
Power Query M language specification
Introduction
Lexical Structure
Basic Concepts
Values
Types
Operators
Let
Conditionals
Functions
Error Handling
Sections
Consolidated Grammar
Power Query M type system
Expressions, values, and let expression
Comments
Evaluation model
Operators
Type conversion
Metadata
Errors
Functions
Functions overview
Understanding Power Query M functions
Accessing data functions
Accessing data functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Binary functions
Binary functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
BinaryFormat.7BitEncodedSignedInteger
BinaryFormat.7BitEncodedUnsignedInteger
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
BinaryFormat.SignedInteger16
BinaryFormat.SignedInteger32
BinaryFormat.SignedInteger64
[Link]
[Link]
[Link]
BinaryFormat.UnsignedInteger16
BinaryFormat.UnsignedInteger32
BinaryFormat.UnsignedInteger64
#binary
Combiner functions
Combiner functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
Comparer functions
Comparer functions overview
[Link]
[Link]
[Link]
[Link]
Date functions
Date functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
#date
DateTime functions
DateTime functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
#datetime
DateTimeZone functions
DateTimeZone functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
#datetimezone
Duration functions
Duration functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
#duration
Error handling functions
Error handling functions overview
[Link]
[Link]
[Link]
Expression functions
Expression functions overview
[Link]
[Link]
[Link]
Function values
Function values overview
[Link]
[Link]
[Link]
[Link]
[Link]
Lines functions
Lines functions overview
[Link]
[Link]
[Link]
[Link]
List functions
List functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Logical functions
Logical functions overview
[Link]
[Link]
[Link]
Number functions
Number functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Number.Atan2
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Number.Log10
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Record functions
Record functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Replacer functions
Replacer functions overview
[Link]
[Link]
Splitter functions
Splitter functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Table functions
Table functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
#table
Text functions
Text functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Time functions
Time functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
#time
Type functions
Type functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Uri functions
Uri functions overview
[Link]
[Link]
[Link]
[Link]
Value functions
Value functions overview
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Enumerations
Enumerations
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]
Constants
Constants
Number.E
[Link]
[Link]
[Link]
[Link]
[Link]
Dynamic values
Dynamic values
[Link]
[Link]
Quick tour of the Power Query M formula language
9/13/2022 • 2 minutes to read

This quick tour describes creating Power Query M formula language queries.

NOTE
M is a case-sensitive language.

Create a query with Query Editor


To create an advanced query, you use the Quer y Editor . A mashup query is composed of variables,
expressions, and values encapsulated by a let expression. A variable can contain spaces by using the # identifier
with the name in quotes as in #"Variable name" .
A let expression follows this structure:

let
Variablename = expression,
#"Variable name" = expression2
in
Variablename

To create an M query in the Quer y Editor , you follow this basic process:
1. Create a series of query formula steps that start with the let statement. Each step is defined by a step
variable name. An M variable can include spaces by using the # character as #"Step Name" . A formula
step can be a custom formula. Note that the Power Query Formula Language is case sensitive.
2. Each query formula step builds upon a previous step by referring to a step by its variable name.
3. Output a query formula step using the in statement. Generally, the last query step is used as the in final
data set result.
To learn more about expressions and values, go to Expressions, values, and let expression.

Simple Power Query M formula steps


Let's assume you created the following transform in the Quer y Editor to convert product names to proper
case.
You have a table that looks like this:

O RDERID C USTO M ERID IT EM P RIC E

1 1 fishing rod 100

2 1 1 lb. worms 5

3 2 fishing net 25

And, you want to capitalize each word in the Item column to produce the following table:

O RDERID C USTO M ERID IT EM P RIC E

1 1 Fishing Rod 100

2 1 1 Lb. Worms 5

3 2 Fishing Net 25

The M formula steps to project the original table into the results table look like this:
Here's the code you can paste into the Power Query editor:

let Orders = [Link]({


[OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}),
#"Capitalized Each Word" = [Link](Orders, {"Item", [Link]})
in
#"Capitalized Each Word"

Let’s review each formula step.


1. Orders – Create a [Table](#_Table_value) with data for Orders.
2. #"Capitalized Each Word" – To capitalize each word, you use [Link].
3. in #"Capitalized Each Word" – Output the table with each word capitalized.

See also
Expressions, values, and let expression
Operators
Type conversion
Power Query M language specification
9/13/2022 • 2 minutes to read

The specification describes the values, expressions, environments and variables, identifiers, and the evaluation
model that form the Power Query M language's basic concepts.
The specification is contained in the following topics.
Introduction
Lexical Structure
Basic Concepts
Values
Types
Operators
Let
Conditionals
Functions
Error Handling
Sections
Consolidated Grammar
Introduction
9/13/2022 • 12 minutes to read

Overview
Microsoft Power Query provides a powerful "get data" experience that encompasses many features. A core
capability of Power Query is to filter and combine, that is, to "mash-up" data from one or more of a rich
collection of supported data sources. Any such data mashup is expressed using the Power Query Formula
Language (informally known as "M"). Power Query embeds M documents in in a wide range of Microsoft
products, including Excel, Power BI, Analysis Services, Dataverse to enable repeatable mashup of data.
This document provides the specification for M. After a brief introduction that aims at building some first
intuition and familiarity with the language, the document covers the language precisely in several progressive
steps:
1. The lexical structure defines the set of texts that are lexically valid.
2. Values, expressions, environments and variables, identifiers, and the evaluation model form the
language's basic concepts.
3. The detailed specification of values, both primitive and structured, defines the target domain of the
language.
4. Values have types, themselves a special kind of value, that both characterize the fundamental kinds of
values and carry additional metadata that is specific to the shapes of structured values.
5. The set of operators in M defines what kinds of expressions can be formed.
6. Functions, another kind of special values, provide the foundation for a rich standard library for M and
allow for the addition of new abstractions.
7. Errors can occur when applying operators or functions during expression evaluation. While errors are not
values, there are ways to handle errors that map errors back to values.
8. Let expressions allow for the introduction of auxiliary definitions used to build up complex expressions in
smaller steps.
9. If expressions support conditional evaluation.
10. Sections provide a simple modularity mechanism. (Sections are not yet leveraged by Power Query.)
11. Finally, a consolidated grammar collects the grammar fragments from all other sections of this document
into a single complete definition.
For computer language theorists: the formula language specified in this document is a mostly pure, higher-
order, dynamically typed, partially lazy functional language.

Expressions and values


The central construct in M is the expression. An expression can be evaluated (computed), yielding a single value.
Although many values can be written literally as an expression, a value is not an expression. For example, the
expression 1 evaluates to the value 1; the expressions 1+1 evaluates to the value 2. This distinction is subtle,
but important. Expressions are recipes for evaluation; values are the results of evaluation.
The following examples illustrate the different kinds of values available in M. As a convention, a value is written
using the literal form in which they would appear in an expression that evaluates to just that value. (Note that
the // indicates the start of a comment which continues to the end of the line.)
A primitive value is single-part value, such as a number, logical, text, or null. A null value can be used to
indicate the absence of any data.

123 // A number
true // A logical
"abc" // A text
null // null value

A list value is an ordered sequence of values. M supports infinite lists, but if written as a literal, lists have a
fixed length. The curly brace characters { and } denote the beginning and end of a list.

{123, true, "A"} // list containing a number, a logical, and


// a text
{1, 2, 3} // list of three numbers

A record is a set of fields. A field is a name/value pair where the name is a text value that is unique within
the field's record. The literal syntax for record values allows the names to be written without quotes, a
form also referred to as identifiers. The following shows a record containing three fields named " A ", " B
", and " C ", which have values 1 , 2 , and 3 .

[
A = 1,
B = 2,
C = 3
]

A table is a set of values organized into columns (which are identified by name), and rows. There is no
literal syntax for creating a table, but there are several standard functions that can be used to create
tables from lists or records.
For example:

#table( {"A", "B"}, { {1, 2}, {3, 4} } )

This creates a table of the following shape:

A function is a value that, when invoked with arguments, produces a new value. Function are written by
listing the function's parameters in parentheses, followed by the goes-to symbol => , followed by the
expression defining the function. That expression typically refers to the parameters (by name).

(x, y) => (x + y) / 2`
Evaluation
The evaluation model of the M language is modeled after the evaluation model commonly found in
spreadsheets, where the order of calculation can be determined based on dependencies between the formulas
in the cells.
If you have written formulas in a spreadsheet such as Excel, you may recognize the formulas on the left will
result in the values on the right when calculated:

In M, parts of an expression can reference other parts of the expression by name, and the evaluation process will
automatically determine the order in which referenced expressions are calculated.
We can use a record to produce an expression that's equivalent to the above spreadsheet example. When
initializing the value of a field, we can refer to other fields within the record by using the name of the field, as
follows:

[
A1 = A2 * 2,
A2 = A3 + 1,
A3 = 1
]

The above expression is equivalent to the following (in that both evaluate to equal values):

[
A1 = 4,
A2 = 2,
A3 = 1
]

Records can be contained within, or nest, within other records. We can use the lookup operator ( [] ) to access
the fields of a record by name. For example, the following record has a field named Sales containing a record,
and a field named Total that accesses the FirstHalf and SecondHalf fields of the Sales record:

[
Sales = [ FirstHalf = 1000, SecondHalf = 1100 ],
Total = Sales[FirstHalf] + Sales[SecondHalf]
]

The above expression is equivalent to the following when it is evaluated: \

[
Sales = [ FirstHalf = 1000, SecondHalf = 1100 ],
Total = 2100
]

Records can also be contained within lists. We can use the positional index operator ( {} ) to access an item in a
list by its numeric index. The values within a list are referred to using a zero-based index from the beginning of
the list. For example, the indexes 0 and 1 are used to reference the first and second items in the list below:
[
Sales =
{
[
Year = 2007,
FirstHalf = 1000,
SecondHalf = 1100,
Total = FirstHalf + SecondHalf // 2100
],
[
Year = 2008,
FirstHalf = 1200,
SecondHalf = 1300,
Total = FirstHalf + SecondHalf // 2500
]
},
TotalSales = Sales{0}[Total] + Sales{1}[Total] // 4600
]

List and record member expressions (as well as let expressions, introduced further below) are evaluated using
lazy evaluation, which means that they are evaluated only as needed. All other expressions are evaluated using
eager evaluation, which means that they are evaluated immediately, when encountered during the evaluation
process. A good way to think about this is to remember that evaluating a list or record expression will return a
list or record value that itself remembers how its list items or record fields need to be computed, when
requested (by lookup or index operators).

Functions
In M, a function is a mapping from a set of input values to a single output value. A function is written by first
naming the required set of input values (the parameters to the function) and then providing an expression that
will compute the result of the function using those input values (the body of the function) following the goes-to
( => ) symbol. For example:

(x) => x + 1 // function that adds one to a value


(x, y) => x + y // function that adds two values

A function is a value just like a number or a text value. The following example shows a function which is the
value of an Add field which is then invoked, or executed, from several other fields. When a function is invoked, a
set of values are specified which are logically substituted for the required set of input values within the function
body expression.

[
Add = (x, y) => x + y,
OnePlusOne = Add(1, 1), // 2
OnePlusTwo = Add(1, 2) // 3
]

Library
M includes a common set of definitions available for use from an expression called the standard library, or just
library for short. These definitions consist of a set of named values. The names of values provided by a library
are available for use within an expression without having been defined explicitly by the expression. For example:

Number.E // Euler's number e (2.7182...)


[Link]("Hello", "ll") // 2
Operators
M includes a set of operators that can be used in expressions. Operators are applied to operands to form
symbolic expressions. For example, in the expression 1 + 2 the numbers 1 and 2 are operands and the
operator is the addition operator ( + ).
The meaning of an operator can vary depending on what kind of values its operands are. For example, the plus
operator can be used with other kinds of values than numbers:

1 + 2 // numeric addition: 3
#time(12,23,0) + #duration(0,0,2,0)
// time arithmetic: #time(12,25,0)

Another example of an operator with operand-depending meaning is the combination operator ( & ):

"A" & "BC" // text concatenation: "ABC"


{1} & {2, 3} // list concatenation: {1, 2, 3}
[ a = 1 ] & [ b = 2 ] // record merge: [ a = 1, b = 2 ]

Note that not all combinations of values may be supported by an operator. For example:

1 + "2" // error: adding number and text is not supported

Expressions that, when evaluated, encounter undefined operator conditions evaluate to errors. More on errors in
M later.

Metadata

Metadata is information about a value that is associated with a value. Metadata is represented as a record value,
called a metadata record. The fields of a metadata record can be used to store the metadata for a value.
Every value has a metadata record. If the value of the metadata record has not been specified, then the metadata
record is empty (has no fields).
Metadata records provide a way to associate additional information with any kind of value in an unobtrusive
way. Associating a metadata record with a value does not change the value or its behavior.
A metadata record value y is associated with an existing value x using the syntax x meta y . For example, the
following associates a metadata record with Rating and Tags fields with the text value "Mozart" :

"Mozart" meta [ Rating = 5, Tags = {"Classical"} ]

For values that already carry a non-empty metadata record, the result of applying meta is that of computing the
record merge of the existing and the new metadata record. For example, the following two expressions are
equivalent to each other and to the previous expression:

("Mozart" meta [ Rating = 5 ]) meta [ Tags = {"Classical"} ]


"Mozart" meta ([ Rating = 5 ] & [ Tags = {"Classical"} ])

A metadata record can be accessed for a given value using the [Link] function. In the following
example, the expression in the ComposerRating field accesses the metadata record of the value in the Composer
field, and then accesses the Rating field of the metadata record.

[
Composer = "Mozart" meta [ Rating = 5, Tags = {"Classical"} ],
ComposerRating = [Link](Composer)[Rating] // 5
]

Let expression
Many of the examples shown so far have included all the literal values of the expression in the result of the
expression. The let expression allows a set of values to be computed, assigned names, and then used in a
subsequent expression that follows the in. For example, in our sales data example, we could do:

let
Sales2007 =
[
Year = 2007,
FirstHalf = 1000,
SecondHalf = 1100,
Total = FirstHalf + SecondHalf // 2100
],
Sales2008 =
[
Year = 2008,
FirstHalf = 1200,
SecondHalf = 1300,
Total = FirstHalf + SecondHalf // 2500
]
in Sales2007[Total] + Sales2008[Total] // 4600

The result of the above expression is a number value ( 4600 ) which was computed from the values bound to the
names Sales2007 and Sales2008 .

If expression
The if expression selects between two expressions based on a logical condition. For example:

if 2 > 1 then
2 + 2
else
1 + 1

The first expression ( 2 + 2 ) is selected if the logical expression ( 2 > 1 ) is true, and the second expression (
1 + 1 ) is selected if it is false. The selected expression (in this case 2 + 2 ) is evaluated and becomes the result
of the if expression ( 4 ).

Errors
An error is an indication that the process of evaluating an expression could not produce a value.
Errors are raised by operators and functions encountering error conditions or by using the error expression.
Errors are handled using the try expression. When an error is raised, a value is specified that can be used to
indicate why the error occurred.
let Sales =
[
Revenue = 2000,
Units = 1000,
UnitPrice = if Units = 0 then error "No Units"
else Revenue / Units
],
UnitPrice = try [Link](Sales[UnitPrice])
in "Unit Price: " &
(if UnitPrice[HasError] then UnitPrice[Error][Message]
else UnitPrice[Value])

The above example accesses the Sales[UnitPrice] field and formats the value producing the result:

"Unit Price: 2"

If the Units field had been zero, then the UnitPrice field would have raised an error which would have been
handled by the try . The resulting value would then have been:

"No Units"

A try expression converts proper values and errors into a record value that indicates whether the try
expression handled and error, or not, and either the proper value or the error record it extracted when handling
the error. For example, consider the following expression that raises an error and then handles it right away:

try error "negative unit count"

This expression evaluates to the following nested record value, explaining the [HasError] , [Error] , and
[Message] field lookups in the unit-price example before.

[
HasError = true,
Error =
[
Reason = "[Link]",
Message = "negative unit count",
Detail = null
]
]

A common case is to replace errors with default values. The try expression can be used with an optional
otherwise clause to achieve just that in a compact form:

try error "negative unit count" otherwise 42


// 42
Lexical Structure
9/13/2022 • 9 minutes to read

Documents
An M document is an ordered sequence of Unicode characters. M allows different classes of Unicode characters
in different parts of an M document. For information on Unicode character classes, see The Unicode Standard,
Version 3.0, section 4.5.
A document either consists of exactly one expression or of groups of definitions organized into sections.
Sections are described in detail in Chapter 10. Conceptually speaking, the following steps are used to read an
expression from a document:
1. The document is decoded according to its character encoding scheme into a sequence of Unicode
characters.
2. Lexical analysis is performed, thereby translating the stream of Unicode characters into a stream of
tokens. The remaining subsections of this section cover lexical analysis.
3. Syntactic analysis is performed, thereby translating the stream of tokens into a form that can be
evaluated. This process is covered in subsequent sections.

Grammar conventions
The lexical and syntactic grammars are presented using grammar productions. Each grammar production
defines a non-terminal symbol and the possible expansions of that nonterminal symbol into sequences of non-
terminal or terminal symbols. In grammar productions, non-terminal+ symbols are shown in italic type, and
terminal symbols are shown in a fixed-width font.
The first line of a grammar production is the name of the non-terminal symbol being defined, followed by a
colon. Each successive indented line contains a possible expansion of the nonterminal given as a sequence of
non-terminal or terminal symbols. For example, the production:
if-expression:
if if-condition then true-expression else false-expression
defines an if-expression to consist of the token if , followed by an if-condition, followed by the token then ,
followed by a true-expression, followed by the token else , followed by a false-expression.
When there is more than one possible expansion of a non-terminal symbol, the alternatives are listed on
separate lines. For example, the production:
variable-list:
variable
variable-list , variable
defines a variable-list to either consist of a variable or consist of a variable-list followed by a variable. In other
words, the definition is recursive and specifies that a variable list consists of one or more variables, separated by
commas.
A subscripted suffix "opt" is used to indicate an optional symbol. The production:
field-specification:
optional opt field-name = field-type
is shorthand for:
field-specification:
field-name = field-type
optional field-name = field-type

and defines a field-specification to optionally begin with the terminal symbol optional followed by a field-
name, the terminal symbol = , and a field-type.
Alternatives are normally listed on separate lines, though in cases where there are many alternatives, the phrase
"one of" may precede a list of expansions given on a single line. This is simply shorthand for listing each of the
alternatives on a separate line. For example, the production:
decimal-digit: one of
0 1 2 3 4 5 6 7 8 9

is shorthand for:
decimal-digit:
0
1
2
3
4
5
6
7
8
9

Lexical Analysis
The lexical-unit production defines the lexical grammar for an M document. Every valid M document conforms
to this grammar.
lexical-unit:
lexical-elementsopt
lexical-elements:
lexical-element
lexical-element
lexical-elements
lexical-element:
whitespace
token comment
At the lexical level, an M document consists of a stream of whitespace, comment, and token elements. Each of
these productions is covered in the following sections. Only token elements are significant in the syntactic
grammar.

Whitespace
Whitespace is used to separate comments and tokens within an M document. Whitespace includes the space
character (which is part of Unicode class Zs), as well as horizontal and vertical tab, form feed, and newline
character sequences. Newline character sequences include carriage return, line feed, carriage return followed by
line feed, next line, and paragraph separator characters.
whitespace:
Any character with Unicode class Zs
Horizontal tab character ( U+0009 )
Vertical tab character ( U+000B )
Form feed character ( U+000C )
Carriage return character ( U+000D ) followed by line feed character ( U+000A )
new-line-character
new-line-character:
Carriage return character ( U+000D )
Line feed character ( U+000A )
Next line character ( U+0085 )
Line separator character ( U+2028 )
Paragraph separator character ( U+2029 )
For compatibility with source code editing tools that add end-of-file markers, and to enable a document to be
viewed as a sequence of properly terminated lines, the following transformations are applied, in order, to an M
document:
If the last character of the document is a Control-Z character ( U+001A ), this character is deleted.
A carriage-return character ( U+000D ) is added to the end of the document if that document is non-empty
and if the last character of the document is not a carriage return ( U+000D ), a line feed ( U+000A ), a line
separator ( U+2028 ), or a paragraph separator ( U+2029 ).

Comments
Two forms of comments are supported: single-line comments and delimited comments. Single-line comments
start with the characters // and extend to the end of the source line. Delimited comments start with the
characters /* and end with the characters */ .
Delimited comments may span multiple lines.
comment:
single-line-comment
delimited-comment
single-line-comment:
// single-line-comment-charactersopt
single-line-comment-characters:
single-line-comment-character single-line-comment-charactersopt
single-line-comment-character:
Any Unicode character except a new-line-character
delimited-comment:
/* delimited-comment-textopt asterisks /
delimited-comment-text:
delimited-comment-section delimited-comment-textopt
delimited-comment-section:
/
asterisksopt not-slash-or-asterisk
asterisks:
* asterisksopt
not-slash-or-asterisk:
Any Unicode character except * or /

Comments do not nest. The character sequences /* and */ have no special meaning within a single-line
comment, and the character sequences // and /* have no special meaning within a delimited comment.
Comments are not processed within text literals. The example

/* Hello, world
*/
"Hello, world"

includes a delimited comment.


The example

// Hello, world
//
"Hello, world" // This is an example of a text literal

shows several single-line comments.

Tokens
A token is an identifier, keyword, literal, operator, or punctuator. Whitespace and comments are used to separate
tokens, but are not considered tokens.
token:
identifier
keyword
literal
operator-or-punctuator
Character Escape Sequences
M text values can contain arbitrary Unicode characters. Text literals, however, are limited to graphic characters
and require the use of escape sequences for non-graphic characters. For example, to include a carriage-return,
linefeed, or tab character in a text literal, the #(cr) , #(lf) , and #(tab) escape sequences can be used,
respectively. To embed the escapesequence start characters #( in a text literal, the # itself needs to be escaped:

#(#)(

Escape sequences can also contain short (four hex digits) or long (eight hex digits) Unicode code-point values.
The following three escape sequences are therefore equivalent:

#(000D) // short Unicode hexadecimal value


#(0000000D) // long Unicode hexadecimal value
#(cr) // compact escape shorthand for carriage return

Multiple escape codes can be included in a single escape sequence, separated by commas; the following two
sequences are thus equivalent:

#(cr,lf)
#(cr)#(lf)

The following describes the standard mechanism of character escaping in an M document.


character-escape-sequence:
#( escape-sequence-list )
escape-sequence-list:
single-escape-sequence
single-escape-sequence , escape-sequence-list
single-escape-sequence:
long-unicode-escape-sequence
short-unicode-escape-sequence
control-character-escape-sequence
escape-escape
long-unicode-escape-sequence:
hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit
short-unicode-escape-sequence:
hex-digit hex-digit hex-digit hex-digit
control-character-escape-sequence:
control-character
control-character:
cr
lf
tab
escape-escape:
#

Literals
A literal is a source code representation of a value.
literal:
logical-literal
number-literal
text-literal
null-literal
verbatim-literal
Null literals
The null literal is used to write the null value. The null value represents an absent value.
null-literal:
null

Logical literals
A logical literal is used to write the values true and false and produces a logical value.
logical-literal:
true
false

Number literals
A number literal is used to write a numeric value and produces a number value.
number-literal:
decimal-number-literal
hexadecimal-number-literal
decimal-number-literal:
decimal-digits . decimal-digits exponent-partopt
. decimal-digits exponent-partopt
decimal-digits exponent-partopt
decimal-digits:
decimal-digit decimal-digitsopt
decimal-digit: one of
0 1 2 3 4 5 6 7 8 9
exponent-part:
e signopt decimal-digits
E signopt decimal-digits
sign: one of
+ -
hexadecimal-number-literal:
0x hex-digits
0X hex-digits
hex-digits:
hex-digit hex-digitsopt
hex-digit: one of
0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f

A number can be specified in hexadecimal format by preceding the hex-digits with the characters 0x . For
example:

0xff // 255

Note that if a decimal point is included in a number literal, then it must have at least one digit following it. For
example, 1.3 is a number literal but 1. and 1.e3 are not.
Text literals
A text literal is used to write a sequence of Unicode characters and produces a text value.
text-literal:
" text-literal-charactersopt "
text-literal-characters:
text-literal-character text-literal-charactersopt
text-literal-character:
single-text-character
character-escape-sequence
double-quote-escape-sequence
single-text-character:
Any character except " ( U+0022 ) or # ( U+0023 ) followed by ( ( U+0028 )
double-quote-escape-sequence:
"" ( U+0022 , U+0022 )

To include quotes in a text value, the quote mark is repeated, as follows:

"The ""quoted"" text" // The "quoted" text

The character-escape-sequence production can be used to write characters in text values without having to
directly encode them as Unicode characters in the document. For example, a carriage return and line feed can be
written in a text value as:

"Hello world#(cr,lf)"

Verbatim literals
A verbatim literal is used to store a sequence of Unicode characters that were entered by a user as code, but
which cannot be correctly parsed as code. At runtime, it produces an error value.
verbatim-literal:
#!" text-literal-charactersopt "

Identifiers
An identifier is a name used to refer to a value. Identifiers can either be regular identifiers or quoted identifiers.
identifier:
regular-identifier
quoted-identifier
regular-identifier:
available-identifier
available-identifier dot-character regular-identifier
available-identifier:
A keyword-or-identifier that is not a keyword
keyword-or-identifier:
identifier-start-character identifier-part-charactersopt
identifier-start-character:
letter-character
underscore-character
identifier-part-characters:
identifier-part-character identifier-part-charactersopt
identifier-part-character:
letter-character
decimal-digit-character
underscore-character
connecting-character
combining-character
formatting-character
dot-character:
. ( U+002E )
underscore-character:
_ ( U+005F )
letter-character:
A Unicode character of classes Lu, Ll, Lt, Lm, Lo, or Nl
combining-character:
A Unicode character of classes Mn or Mc
decimal-digit-character:
A Unicode character of the class Nd
connecting-character:
A Unicode character of the class Pc
formatting-character:
A Unicode character of the class Cf
A quoted-identifier can be used to allow any sequence of zero or more Unicode characters to be used as an
identifier, including keywords, whitespace, comments, operators and punctuators.
quoted-identifier:
#" text-literal-charactersopt "

Note that escape sequences and double-quotes to escape quotes can be used in a quoted identifier, just as in a
text-literal.
The following example uses identifier quoting for names containing a space character:
[
#"1998 Sales" = 1000,
#"1999 Sales" = 1100,
#"Total Sales" = #"1998 Sales" + #"1999 Sales"
]

The following example uses identifier quoting to include the + operator in an identifier:

[
#"A + B" = A + B,
A = 1,
B = 2
]

Generalized Identifiers
There are two places in M where no ambiguities are introduced by identifiers that contain blanks or that are
otherwise keywords or number literals. These places are the names of record fields in a record literal and in a
field access operator ( [ ] ) There, M allows such identifiers without having to use quoted identifiers.

[
Data = [ Base Line = 100, Rate = 1.8 ],
Progression = Data[Base Line] * Data[Rate]
]

The identifiers used to name and access fields are referred to as generalized identifiers and defined as follows:
generalized-identifier:
generalized-identifier-part
generalized-identifier separated only by blanks ( U+0020 )
generalized-identifier-part
generalized-identifier-part:
generalized-identifier-segment
decimal-digit-character generalized-identifier-segment
generalized-identifier-segment:
keyword-or-identifier
keyword-or-identifier dot-character keyword-or-identifier
Keywords
A keyword is an identifier-like sequence of characters that is reserved, and cannot be used as an identifier except
when using the identifier-quoting mechanism or where a generalized identifier is allowed.
keyword: one of
and as each else error false if in is let meta not null or otherwise
section shared then true try type #binary #date #datetime
#datetimezone #duration #infinity #nan #sections #shared #table #time

Operators and punctuators


There are several kinds of operators and punctuators. Operators are used in expressions to describe operations
involving one or more operands. For example, the expression a + b uses the + operator to add the two
operands a and b . Punctuators are for grouping and separating.
operator-or-punctuator: one of
, ; = < <= > >= <> + - * / & ( ) [ ] { } @ ! ? ?? => .. ...
Basic concepts
9/13/2022 • 8 minutes to read

This section discusses basic concepts that appear throughout the subsequent sections.

Values
A single piece of data is called a value. Broadly speaking, there are two general categories of values: primitive
values, which are atomic, and structured values, which are constructed out of primitive values and other
structured values. For example, the values

1
true
3.14159
"abc"

are primitive in that they are not made up of other values. On the other hand, the values

{1, 2, 3}
[ A = {1}, B = {2}, C = {3} ]

are constructed using primitive values and, in the case of the record, other structured values.

Expressions
An expression is a formula used to construct values. An expression can be formed using a variety of syntactic
constructs. The following are some examples of expressions. Each line is a separate expression.

"Hello World" // a text value


123 // a number
1 + 2 // sum of two numbers
{1, 2, 3} // a list of three numbers
[ x = 1, y = 2 + 3 ] // a record containing two fields:
// x and y
(x, y) => x + y // a function that computes a sum
if 2 > 1 then 2 else 1 // a conditional expression
let x = 1 + 1 in x * 2 // a let expression
error "A" // error with message "A"

The simplest form of expression, as seen above, is a literal representing a value.


More complex expressions are built from other expressions, called sub-expressions. For example:

1 + 2

The above expression is actually composed of three expressions. The 1 and 2 literals are subexpressions of
the parent expression 1 + 2 .
Executing the algorithm defined by the syntactic constructs used in an expression is called evaluating the
expression. Each kind of expression has rules for how it is evaluated. For example, a literal expression like 1 will
produce a constant value, while the expression a + b will take the resulting values produced by evaluating two
other expressions ( a and b ) and add them together according to some set of rules.

Environments and variables


Expressions are evaluated within a given environment. An environment is a set of named values, called
variables. Each variable in an environment has a unique name within the environment called an identifier.
A top-level (or root) expression is evaluated within the global environment. The global environment is provided
by the expression evaluator instead of being determined from the contents of the expression being evaluated.
The contents of the global environment includes the standard library definitions and can be affected by exports
from sections from some set of documents. (For simplicity, the examples in this section will assume an empty
global environment. That is, it is assumed that there is no standard library and that there are no other section-
based definitions.)
The environment used to evaluate a sub-expression is determined by the parent expression. Most parent
expression kinds will evaluate a sub-expression within the same environment they were evaluated within, but
some will use a different environment. The global environment is the parent environment within which the
global expression is evaluated.
For example, the record-initializer-expression evaluates the sub-expression for each field with a modified
environment. The modified environment includes a variable for each of the fields of the record, except the one
being initialized. Including the other fields of the record allows the fields to depend upon the values of the fields.
For example:

[
x = 1, // environment: y, z
y = 2, // environment: x, z
z = x + y // environment: x, y
]

Similarly, the let-expression evaluates the sub-expression for each variable with an environment containing each
of the variables of the let except the one being initialized. The let-expression evaluates the expression following
the in with an environment containing all the variables:

let

x = 1, // environment: y, z
y = 2, // environment: x, z
z = x + y // environment: x, y
in
x + y + z // environment: x, y, z

(It turns out that both record-initializer-expression and let-expression actually define two environments, one of
which does include the variable being initialized. This is useful for advanced recursive definitions and is covered
in Identifier references .
To form the environments for the sub-expressions, the new variables are "merged" with the variables in the
parent environment. The following example shows the environments for nested records:
[
a =
[

x = 1, // environment: b, y, z
y = 2, // environment: b, x, z
z = x + y // environment: b, x, y
],
b = 3 // environment: a
]

The following example shows the environments for a record nested within a let:

Let
a =
[
x = 1, // environment: b, y, z
y = 2, // environment: b, x, z
z = x + y // environment: b, x, y
],
b = 3 // environment: a
in
a[z] + b // environment: a, b

Merging variables with an environment may introduce a conflict between variables (since each variable in an
environment must have a unique name). The conflict is resolved as follows: if the name of a new variable being
merged is the same as an existing variable in the parent environment, then the new variable will take
precedence in the new environment. In the following example, the inner (more deeply nested) variable x will
take precedence over the outer variable x .

[
a =
[
x = 1, // environment: b, x (outer), y, z
y = 2, // environment: b, x (inner), z
z = x + y // environment: b, x (inner), y
],
b = 3, // environment: a, x (outer)
x = 4 // environment: a, b
]

Identifier references
An identifier-reference is used to refer to a variable within an environment.
identifier-expression:
identifier-reference
identifier-reference:
exclusive-identifier-reference
inclusive-identifier-reference
The simplest form of identifier reference is an exclusive-identifier-reference:
exclusive-identifier-reference:
identifier
It is an error for an exclusive-identifier-reference to refer to a variable that is not part of the environment of the
expression that the identifier appears within.
It is an error for an exclusive-identifier-reference to refer to an identifier that is currently being initialized if the
referenced identifier is defined inside a record-initializer-expression or let-expression. Instead, an inclusive-
identifier-reference can be used to gain access to the environment that includes the identifier being initialized. If
an inclusive-identifier-reference is used in any other situation, then it is equivalent to an exclusive-identifier-
reference.
inclusive-identifier-reference:
@ identifier

This is useful when defining recursive functions since the name of the function would normally not be in scope.

[
Factorial = (n) =>
if n <= 1 then
1
else
n * @Factorial(n - 1), // @ is scoping operator

x = Factorial(5)
]

As with a record-initializer-expression, an inclusive-identifier-reference can be used within a let-expression to


access the environment that includes the identifier being initialized.

Order of evaluation
Consider the following expression which initializes a record:

[
C = A + B,
A = 1 + 1,
B = 2 + 2
]

When evaluated, this expression produces the following record value:

[
C = 6,
A = 2,
B = 4
]

The expression states that in order to perform the A + B calculation for field C , the values of both field A and
field B must be known. This is an example of a dependency ordering of calculations that is provided by an
expression. The M evaluator abides by the dependency ordering provided by expressions, but is free to perform
the remaining calculations in any order it chooses. For example, the computation order could be:

A = 1 + 1
B = 2 + 2
C = A + B

Or it could be:
B = 2 + 2
A = 1 + 1
C = A + B

Or, since A and B do not depend on each other, they can be computed concurrently:
B = 2 + 2 concurrently with A = 1 + 1
C = A + B

Side effects
Allowing an expression evaluator to automatically compute the order of calculations for cases where there are
no explicit dependencies stated by the expression is a simple and powerful computation model.
It does, however, rely on being able to reorder computations. Since expressions can call functions, and those
functions could observe state external to the expression by issuing external queries, it is possible to construct a
scenario where the order of calculation does matter, but is not captured in the partial order of the expression.
For example, a function may read the contents of a file. If that function is called repeatedly, then external changes
to that file can be observed and, therefore, reordering can cause observable differences in program behavior.
Depending on such observed evaluation ordering for the correctness of an M expression causes a dependency
on particular implementation choices that might vary from one evaluator to the next or may even vary on the
same evaluator under varying circumstances.

Immutability
Once a value has been calculated, it is immutable, meaning it can no longer be changed. This simplifies the
model for evaluating an expression and makes it easier to reason about the result since it is not possible to
change a value once it has been used to evaluate a subsequent part of the expression. For instance, a record
field is only computed when needed. However, once computed, it remains fixed for the lifetime of the record.
Even if the attempt to compute the field raised an error, that same error will be raised again on every attempt to
access that record field.
An important exception to the immutable-once-calculated rule applies to list and table values. Both have
streaming semantics. That is, repeated enumeration of the items in a list or the rows in a table can produce
varying results. Streaming semantics enables the construction of M expressions that transform data sets that
would not fit in memory at once.
Also, note that function application is not the same as value construction. Library functions may expose external
state (such as the current time or the results of a query against a database that evolves over time), rendering
them non-deterministic. While functions defined in M will not, as such, expose any such non-deterministic
behavior, they can if they are defined to invoke other functions that are non-deterministic.
A final source of non-determinism in M are errors. Errors stop evaluations when they occur (up to the level
where they are handled by a try expression). It is not normally observable whether a + b caused the evaluation
of a before b or b before a (ignoring concurrency here for simplicity). However, if the subexpression that
was evaluated first raises an error, then it can be determined which of the two expressions was evaluated first.
Values
9/13/2022 • 17 minutes to read

A value is data produced by evaluating an expression. This section describes the kinds of values in the M
language. Each kind of value is associated with a literal syntax, a set of values that are of that kind, a set of
operators defined over that set of values, and an intrinsic type ascribed to newly constructed values.

K IN D L IT ERA L

Null null

Logical true false

Number 0 1 -1 1.5 2.3e-5

Time #time(09,15,00)

Date #date(2013,02,26)

DateTime #datetime(2013,02,26, 09,15,00)

DateTimeZone #datetimezone(2013,02,26, 09,15,00, 09,00)

Duration #duration(0,1,30,0)

Text "hello"

Binary #binary("AQID")

List {1, 2, 3}

Record [ A = 1, B = 2 ]

Table #table({"X","Y"},{{0,1},{1,0}})

Function (x) => x + 1

Type type { number } type table [ A = any, B = text ]

The following sections cover each value kind in detail. Types and type ascription are defined formally in Types.
Function values are defined in Functions. The following sections list the operators defined for each value kind
and give examples. The full definition of operator semantics follows in Operators.

Null
A null value is used to represent the absence of a value, or a value of indeterminate or unknown state. A null
value is written using the literal null . The following operators are defined for null values:
O P ERATO R RESULT

x > y Greater than

x >= y Greater than or equal

x < y Less than

x <= y Less than or equal

x = y Equal

x <> y Not equal

x ?? y Coalesce

The native type of the null value is the intrinsic type null .

Logical
A logical value is used for Boolean operations has the value true or false. A logical value is written using the
literals true and false . The following operators are defined for logical values:

O P ERATO R RESULT

x > y Greater than

x >= y Greater than or equal

x < y Less than

x <= y Less than or equal

x = y Equal

x <> y Not equal

x or y Conditional logical OR

x ?? y Coalesce

x and y Conditional logical AND

not x Logical NOT

The native type of both logical values ( true and false ) is the intrinsic type logical .

Number
A number value is used for numeric and arithmetic operations. The following are examples of number literals:
3.14 // Fractional number
-1.5 // Fractional number
1.0e3 // Fractional number with exponent
123 // Whole number
1e3 // Whole number with exponent
0xff // Whole number in hex (255)

A number is represented with at least the precision of a Double (but may retain more precision). The Double
representation is congruent with the IEEE 64-bit double precision standard for binary floating point arithmetic
defined in [IEEE 754-2008]. (The Double representation have an approximate dynamic range from 5.0 x 10324 to
1.7 x 10308 with a precision of 15-16 digits.)
The following special values are also considered to be number values:
Positive zero and negative zero. In most situations, positive zero and negative zero behave identically as
the simple value zero, but certain operations distinguish between the two.
Positive infinity ( #infinity ) and negative infinity ( -#infinity ). Infinities are produced by such
operations as dividing a non-zero number by zero. For example, 1.0 / 0.0 yields positive infinity, and
-1.0 / 0.0 yields negative infinity.

The Not-a-Number value ( #nan ), often abbreviated NaN. NaNs are produced by invalid floating-point
operations, such as dividing zero by zero.
Binary mathematical operations are performed using a Precision. The precision determines the domain to which
the operands are rounded and the domain in which the operation is performed. In the absence of an explicitly
specified precision, such operations are performed using Double Precision.
If the result of a mathematical operation is too small for the destination format, the result of the
operation becomes positive zero or negative zero.
If the result of a mathematical operation is too large for the destination format, the result of the operation
becomes positive infinity or negative infinity.
If a mathematical operation is invalid, the result of the operation becomes NaN.
If one or both operands of a floating-point operation is NaN, the result of the operation becomes NaN.
The following operators are defined for number values:

O P ERATO R RESULT

x > y Greater than

x >= y Greater than or equal

x < y Less than

x <= y Less than or equal

x = y Equal

x <> y Not equal

x + y Sum
O P ERATO R RESULT

x - y Difference

x * y Product

x / y Quotient

x ?? y Coalesce

+x Unary plus

-x Negation

The native type of number values is the intrinsic type number .

Time
A time value stores an opaque representation of time of day. A time is encoded as the number of ticks since
midnight, which counts the number of 100-nanosecond ticks that have elapsed on a 24-hour clock. The
maximum number of ticks since midnight corresponds to [Link].9999999 hours.
Time values may be constructed using the #time instrinsic.

#time(hour, minute, second)

The following must hold or an error with reason code [Link] is raised:
0 ≤ hour ≤ 24
0 ≤ minute ≤ 59
0 ≤ second ≤ 59
In addition, if hour = 24, then minute and second must be zero.
The following operators are defined for time values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal

x > y Greater than

x < y Less than

x <= y Less than or equal

x ?? y Coalesce

The following operators permit one or both of their operands to be a date:


O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x + y time duration Date offset by duration

x + y duration time Date offset by duration

x - y time duration Date offset by negated


duration

x - y time time Duration between dates

x & y date time Merged datetime

The native type of time values is the intrinsic type time .

Date
A date value stores an opaque representation of a specific day. A date is encoded as a number of days since
epoch, starting from January 1, 0001 Common Era on the Gregorian calendar. The maximum number of days
since epoch is 3652058, corresponding to December 31, 9999.
Date values may be constructed using the #date intrinsic.

#date(year, month, day)

The following must hold or an error with reason code [Link] is raised:
1 ≤ year ≤ 9999
1 ≤ month ≤ 12
1 ≤ day ≤ 31
In addition, the day must be valid for the chosen month and year.
The following operators are defined for date values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal

x > y Greater than

x < y Less than

x <= y Less than or equal

x ?? y Coalesce

The following operators permit one or both of their operands to be a date:


O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x + y date duration Date offset by duration

x + y duration date Date offset by duration

x - y date duration Date offset by negated


duration

x - y date date Duration between dates

x & y date time Merged datetime

The native type of date values is the intrinsic type date .

DateTime
A datetime value contains both a date and time.
DateTime values may be constructed using the #datetime intrinsic.

#datetime(year, month, day, hour, minute, second)

The following must hold or an error with reason code [Link] is raised: 1 ≤ year ≤ 9999
1 ≤ month ≤ 12
1 ≤ day ≤ 31
0 ≤ hour ≤ 23
0 ≤ minute ≤ 59
0 ≤ second ≤ 59
In addition, the day must be valid for the chosen month and year.
The following operators are defined for datetime values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal

x > y Greater than

x < y Less than

x <= y Less than or equal

x ?? y Coalesce

The following operators permit one or both of their operands to be a datetime:


O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x + y datetime duration Datetime offset by duration

x + y duration datetime Datetime offset by duration

x - y datetime duration Datetime offset by negated


duration

x - y datetime datetime Duration between


datetimes

The native type of datetime values is the intrinsic type datetime .

DateTimeZone
A datetimezone value contains a datetime and a timezone. A timezone is encoded as a number of minutes offset
from UTC, which counts the number of minutes the time portion of the datetime should be offset from Universal
Coordinated Time (UTC). The minimum number of minutes offset from UTC is -840, representing a UTC offset of
-14:00, or fourteen hours earlier than UTC. The maximum number of minutes offset from UTC is 840,
corresponding to a UTC offset of 14:00.
DateTimeZone values may be constructed using the #datetimezone intrinsic.

#datetimezone(
year, month, day,
hour, minute, second,
offset-hours, offset-minutes)

The following must hold or an error with reason code [Link] is raised:
1 ≤ year ≤ 9999
1 ≤ month ≤ 12
1 ≤ day ≤ 31
0 ≤ hour ≤ 23
0 ≤ minute ≤ 59
0 ≤ second ≤ 59
-14 ≤ offset-hours ≤ 14
-59 ≤ offset-minutes ≤ 59
In addition, the day must be valid for the chosen month and year and, if offset-hours = 14, then offset-minutes
<= 0 and, if offset-hours = -14, then offset-minutes >= 0.
The following operators are defined for datetimezone values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal

x > y Greater than


O P ERATO R RESULT

x < y Less than

x <= y Less than or equal

x ?? y Coalesce

The following operators permit one or both of their operands to be a datetimezone:

O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x + y datetimezone duration Datetimezone offset by


duration

x + y duration datetimezone Datetimezone offset by


duration

x - y datetimezone duration Datetimezone offset by


negated duration

x - y datetimezone datetimezone Duration between


datetimezones

The native type of datetimezone values is the intrinsic type datetimezone .

Duration
A duration value stores an opaque representation of the distance between two points on a timeline measured
100-nanosecond ticks. The magnitude of a duration can be either positive or negative, with positive values
denoting progress forwards in time and negative values denoting progress backwards in time. The minimum
value that can be stored in a duration is -9,223,372,036,854,775,808 ticks, or 10,675,199 days 2 hours 48
minutes 05.4775808 seconds backwards in time. The maximum value that can be stored in a duration is
9,223,372,036,854,775,807 ticks, or 10,675,199 days 2 hours 48 minutes 05.4775807 seconds forwards in time.
Duration values may be constructed using the #duration intrinsic function:

#duration(0, 0, 0, 5.5) // 5.5 seconds


#duration(0, 0, 0, -5.5) // -5.5 seconds
#duration(0, 0, 5, 30) // 5.5 minutes
#duration(0, 0, 5, -30) // 4.5 minutes
#duration(0, 24, 0, 0) // 1 day
#duration(1, 0, 0, 0) // 1 day

The following operators are defined on duration values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal


O P ERATO R RESULT

x > y Greater than

x < y Less than

x <= y Less than or equal

x ?? y Coalesce

Additionally, the following operators allow one or both of their operands to be a duration value:

O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x + y datetime duration Datetime offset by duration

x + y duration datetime Datetime offset by duration

x + y duration duration Sum of durations

x - y datetime duration Datetime offset by negated


duration

x - y datetime datetime Duration between


datetimes

x - y duration duration Difference of durations

x * y duration number N times a duration

x * y number duration N times a duration

x / y duration number Fraction of a duration

The native type of duration values is the intrinsic type duration .

Text
A text value represents a sequence of Unicode characters. Text values have a literal form conformant to the
following grammar:
_text-literal:
" text-literal-charactersopt "
text-literal-characters:
text-literal-character text-literal-charactersopt
text-literal-character:
single-text-character
character-escape-sequence
double-quote-escape-sequence
single-text-character:
Any character except " ( U+0022 ) or # ( U+0023 ) followed by ( ( U+0028 )
double-quote-escape-sequence:
"" ( U+0022 , U+0022 )
The following is an example of a text value:

"ABC" // the text value ABC

The following operators are defined on text values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal

x > y Greater than

x < y Less than

x <= y Less than or equal

x & y Concatenation

x ?? y Coalesce

The native type of text values is the intrinsic type text .

Binary
A binary value represents a sequence of bytes. There is no literal format. Several standard library functions are
provided to construct binary values. For example, #binary can be used to construct a binary value from a list of
bytes:

#binary( {0x00, 0x01, 0x02, 0x03} )

The following operators are defined on binary values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x >= y Greater than or equal

x > y Greater than

x < y Less than

x <= y Less than or equal


O P ERATO R RESULT

x ?? y Coalesce

The native type of binary values is the intrinsic type binary.

List
A list value is a value which produces a sequence of values when enumerated. A value produced by a list can
contain any kind of value, including a list. Lists can be constructed using the initialization syntax, as follows:
list-expression:
{ item-listopt }
item-list:
item
item , item-list
item:
expression
expression .. expression
The following is an example of a list-expression that defines a list with three text values: "A" , "B" , and "C" .

{"A", "B", "C"}

The value "A" is the first item in the list, and the value "C" is the last item in the list.
The items of a list are not evaluated until they are accessed.
While list values constructed using the list syntax will produce items in the order they appear in item-list, in
general, lists returned from library functions may produce a different set or a different number of values
each time they are enumerated.
To include a sequence of whole number in a list, the a..b form can be used:

{ 1, 5..9, 11 } // { 1, 5, 6, 7, 8, 9, 11 }

The number of items in a list, known as the list count, can be determined using the [Link] function.

[Link]({true, false}) // 2
[Link]({}) // 0

A list may effectively have an infinite number of items; [Link] for such lists is undefined and may either
raise an error or not terminate.
If a list contains no items, it is called an empty list. An empty list is written as:

{} // empty list

The following operators are defined for lists:

O P ERATO R RESULT

x = y Equal
O P ERATO R RESULT

x <> y Not equal

x & y Concatenate

x ?? y Coalesce

For example:

{1, 2} & {3, 4, 5} // {1, 2, 3, 4, 5}


{1, 2} = {1, 2} // true
{2, 1} <> {1, 2} // true

The native type of list values is the intrinsic type list , which specifies an item type of any .

Record
A record value is an ordered sequence of fields. A field consists of a field name, which is a text value that
uniquely identifies the field within the record, and a field value. The field value can be any kind of value,
including record. Records can be constructed using initialization syntax, as follows:
record-expression:
[ field-listopt ]
field-list:
field
field , field-list
field:
field-name = expression
field-name:
generalized-identifier
quoted-identifier
The following example constructs a record with a field named x with value 1 , and a field named y with value
2 .

[ x = 1, y = 2 ]

The following example constructs a record with a field named a with a nested record value. The nested record
has a field named b with value 2 .

[ a = [ b = 2 ] ]

The following holds when evaluating a record expression:


The expression assigned to each field name is used to determine the value of the associated field.
If the expression assigned to a field name produces a value when evaluated, then that becomes the value
of the field of the resulting record.
If the expression assigned to a field name raises an error when evaluated, then the fact that an error was
raised is recorded with the field along with the error value that was raised. Subsequent access to that field
will cause an error to be re-raised with the recorded error value.
The expression is evaluated in an environment like the parent environment only with variables merged in
that correspond to the value of every field of the record, except the one being initialized.
A value in a record is not evaluated until the corresponding field is accessed.
A value in a record is evaluated at most once.
The result of the expression is a record value with an empty metadata record.
The order of the fields within the record is defined by the order that they appear in the record-initializer-
expression.
Every field name that is specified must be unique within the record, or it is an error. Names are compared
using an ordinal comparison.

[ x = 1, x = 2 ] // error: field names must be unique


[ X = 1, x = 2 ] // OK

A record with no fields is called an empty record, and is written as follows:

[] // empty record

Although the order of the fields of a record is not significant when accessing a field or comparing two records, it
is significant in other contexts such as when the fields of a record are enumerated.
The same two records produce different results when the fields are obtained:

[Link]([ x = 1, y = 2 ]) // [ "x", "y" ]


[Link]([ y = 1, x = 2 ]) // [ "y", "x" ]

The number of fields in a record can be determined using the [Link] function. For example:

[Link]([ x = 1, y = 2 }) // 2
[Link]([]) // 0

In addition to using the record initialization syntax [ ] , records can be constructed from a list of values, and a
list of field names or a record type. For example:

[Link]({1, 2}, {"a", "b"})

The above is equivalent to:

[ a = 1, b = 2 ]

The following operators are defined for record values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal


O P ERATO R RESULT

x & y Merge

x ?? y Coalesce

The following examples illustrate the above operators. Note that record merge uses the fields from the right
operand to override fields from the left operand, should there be an overlap in field names.

[ a = 1, b = 2 ] & [ c = 3 ] // [ a = 1, b = 2, c = 3 ]
[ a = 1, b = 2 ] & [ a = 3 ] // [ a = 3, b = 2 ]
[ a = 1, b = 2 ] = [ b = 2, a = 1 ] // true
[ a = 1, b = 2, c = 3 ] <> [ a = 1, b = 2 ] // true

The native type of record values is the intrinsic type record , which specifies an open empty list of fields.

Table
A table value is an ordered sequence of rows. A row is an ordered sequence of value. The table's type determines
the length of all rows in the table, the names of the table's columns, the types of the table's columns, and the
structure of the table's keys (if any).
There is no literal syntax for tables. Several standard library functions are provided to construct binary values.
For example, #table can be used to construct a table from a list of row lists and a list of header names:

#table({"x", "x^2"}, {{1,1}, {2,4}, {3,9}})

The above example constructs a table with two columns, both of which are of type any .
#table can also be used to specify a full table type:

#table(
type table [Digit = number, Name = text],
{{1,"one"}, {2,"two"}, {3,"three"}}
)

Here the new table value has a table type that specifies column names and column types.
The following operators are defined for table values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x & y Concatenation

x ?? y Coalesce

Table concatenation aligns like-named columns and fills in null for columns appearing in only one of the
operand tables. The following example illustrates table concatenation:
#table({"A","B"}, {{1,2}})
& #table({"B","C"}, {{3,4}})

A B C

1 2 null

null 3 4

The native type of table values is a custom table type (derived from the intrinsic type table ) that lists the
column names, specifies all column types to be any, and has no keys. (Go to Table types for details on table
types.)

Function
A function value is a value that maps a set of arguments to a single value. The details of function values are
described in Functions.

Type
A type value is a value that classifies other values. The details of type values are described in Types.
Types
9/13/2022 • 12 minutes to read

A type value is a value that classifies other values. A value that is classified by a type is said to conform to that
type. The M type system consists of the following kinds of types:
Primitive types, which classify primitive values ( binary , date , datetime , datetimezone , duration ,
list , logical , null , number , record , text , time , type ) and also include a number of abstract types
( function , table , any , and none )
Record types, which classify record values based on field names and value types
List types, which classify lists using a single item base type
Function types, which classify function values based on the types of their parameters and return values
Table types, which classify table values based on column names, column types, and keys
Nullable types, which classifies the value null in addition to all the values classified by a base type
Type types, which classify values that are types
The set of primitive types includes the types of primitive values a number of abstract types, types that do not
uniquely classify any values: function , table , any , and none . All function values conform to the abstract type
function , all table values to the abstract type table , all values to the abstract type any , and no values to the
abstract type none . An expression of type none must raise an error or fail to terminate since no value could be
produced that conforms to type none . Note that the primitive types function and table are abstract because
no function or table is directly of those types, respectively. The primitive types record and list are non-
abstract because they represent an open record with no defined fields and a list of type any, respectively.
All types that are not members of the closed set of primitive types are collectively referred to as custom types.
Custom types can be written using a type-expression :
type-expression:
primary-expression
type primary-type
type:
parenthesized-expression
primary-type
primary-type:
primitive-type
record-type
list-type
function-type
table-type
nullable-type
primitive-type: one of
any binary date datetime datetimezone duration function list logical
none null number record table text time type

The primitive-type names are contextual keywords recognized only in a type context. The use of parentheses in a
type context moves the grammar back to a regular expression context, requiring the use of the type keyword to
move back into a type context. For example, to invoke a function in a type context, parentheses can be used:
type nullable ( [Link]({type number}) )
// type nullable {number}

Parentheses can also be used to access a variable whose name collides with a primitive-type name:

let record = type [ A = any ] in type {(record)}


// type {[ A = any ]}

The following example defines a type that classifies a list of numbers:

type { number }

Similarly, the following example defines a custom type that classifies records with mandatory fields named X
and Y whose values are numbers:

type [ X = number, Y = number ]

The ascribed type of a value is obtained using the standard library function [Link], as shown in the
following examples:

[Link]( 2 ) // type number


[Link]( {2} ) // type list
[Link]( [ X = 1, Y = 2 ] ) // type record

The is operator is used to determine whether a value's type is compatible with a given type, as shown in the
following examples:

1 is number // true
1 is text // false
{2} is list // true

The as operator checks if the value is compatible with the given type, and raises an error if it is not. Otherwise,
it returns the original value.

[Link]( 1 as number ) // type number


{2} as text // error, type mismatch

Note that the is and as operators only accept primitive types as their right operand. M does not provide
means to check values for conformance to custom types.
A type X is compatible with a type Y if and only if all values that conform to X also conform to Y . All types
are compatible with type any and no types (but none itself) are compatible with type none . The following
graph shows the compatibility relation. (Type compatibility is reflexive and transitive. It forms a lattice with type
any as the top and type none as the bottom value.) The names of abstract types are set in italics.
The following operators are defined for type values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

x ?? y Coalesce

The native type of type values is the intrinsic type type .

Primitive Types
Types in the M language form a disjoint hierarchy rooted at type any , which is the type that classifies all values.
Any M value conforms to exactly one primitive subtype of any . The closed set of primitive types deriving from
type any are as follows:
type null , which classifies the null value.
type logical , which classifies the values true and false.
type number , which classifies number values.
type time , which classifies time values.
type date , which classifies date values.
type datetime , which classifies datetime values.
type datetimezone , which classifies datetimezone values.
type duration , which classifies duration values.
type text , which classifies text values.
type binary , which classifies binary values.
type type , which classifies type values.
type list , which classifies list values.
type record , which classifies record values.
type table , which classifies table values.
type function , which classifies function values.
type anynonnull , which classifies all values excluding null. The intrinsic type none classifies no values.

Any Type
The type any is abstract, classifies all values in M, and all types in M are compatible with any . Variables of type
any can be bound to all possible values. Since any is abstract, it cannot be ascribed to values—that is, no value
is directly of type any .

List Types
Any value that is a list conforms to the intrinsic type list , which does not place any restrictions on the items
within a list value.
list-type:
{ item-type }
item-type:
type
The result of evaluating a list-type is a list type value whose base type is list .
The following examples illustrate the syntax for declaring homogeneous list types:

type { number } // list of numbers type


{ record } // list of records type
{{ text }} // list of lists of text values

A value conforms to a list type if the value is a list and each item in that list value conforms to the list type's item
type.
The item type of a list type indicates a bound: all items of a conforming list conform to the item type.

Record Types
Any value that is a record conforms to the intrinsic type record, which does not place any restrictions on the field
names or values within a record value. A record-type value is used to restrict the set of valid names as well as
the types of values that are permitted to be associated with those names.
record-type:
[ open-record-marker ]
[ field-specification-listopt ]
[ field-specification-list , open-record-marker ]
field-specification-list:
field-specification
field-specification , field-specification-list
field-specification:
optional opt field-name field-type-specificationopt
field-type-specification:
= field-type
field-type:
type
open-record-marker:
...

The result of evaluating a record-type is a type value whose base type is record .
The following examples illustrate the syntax for declaring record types:
type [ X = number, Y = number]
type [ Name = text, Age = number ]
type [ Title = text, optional Description = text ]
type [ Name = text, ... ]

Record types are closed by default, meaning that additional fields not present in the fieldspecification-list are not
allowed to be present in conforming values. Including the openrecord-marker in the record type declares the
type to be open, which permits fields not present in the field specification list. The following two expressions are
equivalent:

type record // primitive type classifying all records


type [ ... ] // custom type classifying all records

A value conforms to a record type if the value is a record and each field specification in the record type is
satisfied. A field specification is satisfied if any of the following are true:
A field name matching the specification's identifier exists in the record and the associated value conforms
to the specification's type
The specification is marked as optional and no corresponding field name is found in the record
A conforming value may contain field names not listed in the field specification list if and only if the record type
is open.

Function Types
Any function value conforms to the primitive type function , which does not place any restrictions on the types
of the function's formal parameters or the function's return value. A custom function-type value is used to place
type restrictions on the signatures of conformant function values.
function-type:
function ( parameter-specification-listopt ) function-return-type
parameter-specification-list:
required-parameter-specification-list
required-parameter-specification-list , optional-parameter-specification-list
optional-parameter-specification-list
required-parameter-specification-list:
required-parameter-specification
required-parameter-specification , required-parameter-specification-list
required-parameter-specification:
parameter-specification
optional-parameter-specification-list:
optional-parameter-specification
optional-parameter-specification , optional-parameter-specification-list
optional-parameter-specification:
optional parameter-specification
parameter-specification:
parameter-name parameter-type
function-return-type:
assertion
assertion:
as nullable-primitive-type

The result of evaluating a function-type is a type value whose base type is function .
The following examples illustrate the syntax for declaring function types:

type function (x as text) as number


type function (y as number, optional z as text) as any

A function value conforms to a function type if the return type of the function value is compatible with the
function type's return type and each parameter specification of the function type is compatible to the
positionally corresponding formal parameter of the function. A parameter specification is compatible with a
formal parameter if the specified parameter-type type is compatible with the type of the formal parameter and
the parameter specification is optional if the formal parameter is optional.
Formal parameter names are ignored for the purposes of determining function type conformance.

Table types
A table-type value is used to define the structure of a table value.
table-type:
table row-type
row-type:
[ field-specification-list ]

The result of evaluating a table-type is a type value whose base type is table .
The row type of a table specifies the column names and column types of the table as a closed record type. So
that all table values conform to the type table , its row type is type record (the empty open record type). Thus,
type table is abstract since no table value can have type table 's row type (but all table values have a row type
that is compatible with type table 's row type). The following example shows the construction of a table type:

type table [A = text, B = number, C = binary]


// a table type with three columns named A, B, and C
// of column types text, number, and binary, respectively

A table-type value also carries the definition of a table value's keys. A key is a set of column names. At most one
key can be designated as the table's primary key. (Within M, table keys have no semantic meaning. However, it is
common for external data sources, such as databases or OData feeds, to define keys over tables. Power Query
uses key information to improve performance of advanced functionality, such as cross-source join operations.)
The standard library functions [Link] , [Link] , and [Link] can be used to
obtain the keys of a table type, add a key to a table type, and replace all keys of a table type, respectively.

[Link](tableType, {"A", "B"}, false)


// add a non-primary key that combines values from columns A and B
[Link](tableType, {})
// returns type value with all keys removed

Nullable types
For any type T , a nullable variant can be derived by using nullable-type:
nullable-type:
nullable type
The result is an abstract type that allows values of type T or the value null .
42 is nullable number // true null is
nullable number // true

Ascription of type nullable T reduces to ascription of type null or type T. (Recall that nullable types are
abstract and no value can be directly of abstract type.)

[Link](42 as nullable number) // type number


[Link](null as nullable number) // type null

The standard library functions [Link] and [Link] can be used to test a type for nullability
and to remove nullability from a type.
The following hold (for any type T ):
type T is compatible with type nullable T
[Link](type T) is compatible with type T

The following are pairwise equivalent (for any type T ):


type nullable any
any

[Link](type any)
type anynonnull

type nullable none


type null

[Link](type null)
type none

type nullable nullable T


type nullable T

[Link]([Link](type T))
[Link](type T)

[Link](type nullable T)
[Link](type T)

type nullable ([Link](type T))


type nullable T

Ascribed type of a value


A value's ascribed type is the type to which a value is declared to conform. When a value is ascribed a type, only
a limited conformance check occurs. M does not perform conformance checking beyond a nullable primitive
type. M program authors that choose to ascribe values with type definitions more complex than a nullable
primitive-type must ensure that such values conform to these types.
A value may be ascribed a type using the library function [Link] . The function either returns a new
value with the type ascribed or raises an error if the new type is incompatible with the value's native primitive
type. In particular, the function raises an error when an attempt is made to ascribe an abstract type, such as any .
Library functions may choose to compute and ascribe complex types to results based on the ascribed types of
the input values.
The ascribed type of a value may be obtained using the library function [Link] . For example:

[Link]( [Link]( {1}, type {number} )


// type {number}

Type equivalence and compatibility


Type equivalence is not defined in M. Any two type values that are compared for equality may or may not return
true . However, the relation between those two types (whether true or false ) will always be the same.

Compatibility between a given type and a nullable primitive type can be determined using the library function
[Link] , which accepts an arbitrary type value as its first and a nullable primitive type value as its second
argument:

[Link](type text, type nullable text) // true


[Link](type nullable text, type text) // false
[Link](type number, type text) // false
[Link](type [a=any], type record) // true
[Link](type [a=any], type list) // false

There is no support in M for determining compatibility of a given type with a custom type.
The standard library does include a collection of functions to extract the defining characteristics from a custom
type, so specific compatibility tests can be implemented as M expressions. Below are some examples; consult the
M library specification for full details.

[Link]( type {number} )


// type number
[Link]( type nullable text )
// type text
[Link]( type [A=text, B=time] )
// [ A = [Type = type text, Optional = false],
// B = [Type = type time, Optional = false] ]
[Link]( type table [X=number, Y=date] )
// type [X = number, Y = date]
[Link](
type function (x as number, optional y as text) as number)
// [ x = type number, y = type nullable text ]
[Link](
type function (x as number, optional y as text) as number)
// 1
[Link](
type function (x as number, optional y as text) as number)
// type number
Operator behavior
9/13/2022 • 37 minutes to read

This section defines the behavior of the various M operators.

Operator precedence
When an expression contains multiple operators, the precedence of the operators controls the order in which
the individual operators are evaluated. For example, the expression x + y * z is evaluated as x + (y * z)
because the * operator has higher precedence than the binary + operator. The precedence of an operator is
established by the definition of its associated grammar production. For example, an additive-expression consists
of a sequence of multiplicative-expression's separated by + or - operators, thus giving the + and -
operators lower precedence than the * and / operators.
The parenthesized-expression production can be used to change the default precedence ordering.
parenthesized-expression:
( expression )

For example:

1 + 2 * 3 // 7
(1 + 2) * 3 // 9

The following table summarizes the M operators, listing the operator categories in order of precedence from
highest to lowest. Operators in the same category have equal precedence.

C AT EGO RY EXP RESSIO N DESC RIP T IO N

Primary i Identifier expression


@i

(x) Parenthesized expression

x[i] Lookup

x{y} Item access

x(...) Function invocation

{x, y, ...} List initialization

[ i = x, ... ] Record initialization

... Not implemented

Unary +x Identity

-x Negation
not x Logical negation

Metadata x meta y Associate metadata

Multiplicative x*y Multiplication

x/y Division

Additive x+y Addition

x-y Subtraction

Relational x<y Less than

x>y Greater than

x <= y Less than or equal

x >= y Greater than or equal

Equality x=y Equal

x <> y Not equal

Type assertion x as y Is compatible nullable-primitive type or


error

Type conformance x is y Test if compatible nullable-primitive


type

Logical AND x and y Short-circuiting conjunction

Logical OR x or y Short-circuiting disjunction

Coalesce x ?? y Null coalescing operator

Operators and metadata


Every value has an associated record value that can carry additional information about the value. This record is
referred to as the metadata record for a value. A metadata record can be associated with any kind of value, even
null . The result of such an association is a new value with the given metadata.

A metadata record is just a regular record and can contain any fields and values that a regular record can, and
itself has a metadata record. Associating a metadata record with a value is "non-intrusive". It does not change
the value's behavior in evaluations except for those that explicitly inspect metadata records.
Every value has a default metadata record, even if one has not been specified. The default metadata record is
empty. The following examples show accessing the metadata record of a text value using the [Link]
standard library function:
[Link]( "Mozart" ) // []

Metadata records are generally not preserved when a value is used with an operator or function that constructs
a new value. For example, if two text values are concatenated using the & operator, the metadata of the
resulting text value is the empty record [] . The following expressions are equivalent:

"Amadeus " & ("Mozart" meta [ Rating = 5 ])


"Amadeus " & "Mozart"

The standard library functions [Link] and [Link] can be used to remove all
metadata from a value and to replace a value's metadata (rather than merge metadata into possibly existing
metadata).
The only operator that returns results that carry metadata is the meta operator.

Structurally recursive operators


Values can be cyclic. For example:

let l = {0, @l} in l


// {0, {0, {0, ... }}}
[A={B}, B={A}]
// [A = {{ ... }}, B = {{ ... }}]

M handles cyclic values by keeping construction of records, lists, and tables lazy. An attempt to construct a cyclic
value that does not benefit from interjected lazy structured values yields an error:

[A=B, B=A]
// [A = [Link]("[Link]",
// "A cyclic reference was encountered during evaluation"),
// B = [Link]("[Link]",
// "A cyclic reference was encountered during evaluation"),
// ]

Some operators in M are defined by structural recursion. For instance, equality of records and lists is defined by
the conjoined equality of corresponding record fields and item lists, respectively.
For non-cyclic values, applying structural recursion yields a finite expansion of the value: shared nested values
will be traversed repeatedly, but the process of recursion always terminates.
A cyclic value has an infinite expansion when applying structural recursion. The semantics of M makes no special
accommodations for such infinite expansions—an attempt to compare cyclic values for equality, for instance,
will typically run out of resources and terminate exceptionally.

Selection and Projection Operators


The selection and projection operators allow data to be extracted from list and record values.
Item Access
A value may be selected from a list or table based on its zero-based position within that list or table using an
item-access-expression.
item-access-expression:
item-selection
optional-item-selection
item-selection:
primary-expression { item-selector }
optional-item-selection:
primary-expression { item-selector } ?
item-selector:
expression
The item-access-expression x{y} returns:
For a list x and a number y , the item of list x at position y . The first item of a list is considered to
have an ordinal index of zero. If the requested position does not exist in the list, an error is raised.
For a table x and a number y , the row of table x at position y . The first row of a table is considered
to have an ordinal index of zero. If the requested position does not exist in the table, an error is raised.
For a table x and a record y , the row of table x that matches the field values of record y for fields
with field names that match corresponding table-column names. If there is no unique matching row in
the table, an error is raised.
For example:

{"a","b","c"}{0} // "a"
{1, [A=2], 3}{1} // [A=2]
{true, false}{2} // error
#table({"A","B"},{{0,1},{2,1}}){0} // [A=0,B=1]
#table({"A","B"},{{0,1},{2,1}}){[A=2]} // [A=2,B=1]
#table({"A","B"},{{0,1},{2,1}}){[B=3]} // error
#table({"A","B"},{{0,1},{2,1}}){[B=1]} // error

The item-access-expression also supports the form x{y}? , which returns null when position (or match) y
does not exist in list or table x . If there are multiple matches for y , an error is still raised.
For example:

{"a","b","c"}{0}? // "a"
{1, [A=2], 3}{1}? // [A=2]
{true, false}{2}? // null
#table({"A","B"},{{0,1},{2,1}}){0} // [A=0,B=1]
#table({"A","B"},{{0,1},{2,1}}){[A=2]} // [A=2,B=1]
#table({"A","B"},{{0,1},{2,1}}){[B=3]} // null
#table({"A","B"},{{0,1},{2,1}}){[B=1]} // error

Item access does not force the evaluation of list or table items other than the one being accessed. For example:

{ error "a", 1, error "c"}{1} // 1


{ error "a", error "b"}{1} // error "b"

The following holds when the item access operator x{y} is evaluated:
Errors raised during the evaluation of expressions x or y are propagated.
The expression x produces a list or a table value.
The expression y produces a number value or, if x produces a table value, a record value.
If produces a number value and the value of
y y is negative, an error with reason code
"[Link]" is raised.
If y produces a number value and the value of y is greater than or equal to the count of x , an error
with reason code "[Link]" is raised unless the optional operator form x{y}? is used, in which
case the value null is returned.
If x produces a table value and y produces a record value and there are no matches for y in x , an
error with reason code "[Link]" is raised unless the optional operator form x{y}? is used, in
which case the value null is returned.
If x produces a table value and y produces a record value and there are multiple matches for y in x ,
an error with reason code "[Link]" is raised.

No items in x other than that at position y is evaluated during the process of item selection. (For streaming
lists or tables, the items or rows preceding that at position y are skipped over, which may cause their
evaluation, depending on the source of the list or table.)
Field Access
The field-access-expression is used to select a value from a record or to project a record or table to one with
fewer fields or columns, respectively.
field-access-expression:
field-selection
implicit-target-field-selection
projection
implicit-target-projection
field-selection:
primary-expression field-selector
field-selector:
required-field-selector
optional-field-selector
required-field-selector:
[ field-name ]
optional-field-selector:
[ field-name ] ?
field-name:
generalized-identifier
quoted-identifier
implicit-target-field-selection:
field-selector
projection:
primary-expression required-projection
primary-expression optional-projection
required-projection:
[ required-selector-list ]
optional-projection:
[ required-selector-list ] ?
required-selector-list:
required-field-selector
required-selector-list , required-field-selector
implicit-target-projection:
required-projection
optional-projection
The simplest form of field access is required field selection. It uses the operator x[y] to look up a field in a
record by field name. If the field y does not exist in x , an error is raised. The form x[y]? is used to perform
optional field selection, and returns null if the requested field does not exist in the record.
For example:

[A=1,B=2][B] // 2
[A=1,B=2][C] // error
[A=1,B=2][C]? // null

Collective access of multiple fields is supported by the operators for required record projection and optional
record projection. The operator x[[y1],[y2],...] projects the record to a new record with fewer fields (selected
by y1 , y2 , ... ). If a selected field does not exist, an error is raised. The operator x[[y1],[y2],...] projects
the record to a new record with the fields selected by y1 , y2 , ... ; if a field is missing, null is used instead.
For example:

[A=1,B=2][[B]] // [B=2]
[A=1,B=2][[C]] // error
[A=1,B=2][[B],[C]]? // [B=2,C=null]

The forms [y] and [y]? are supported as a shorthand reference to the identifier _ (underscore). The
following two expressions are equivalent:

[A]
_[A]

The following example illustrates the shorthand form of field access:

let _ = [A=1,B=2] in [A] //1

The form [[y1],[y2],...] and [[y1],[y2],...]? are also supported as a shorthand and the following two
expressions are likewise equivalent:

[[A],[B]]
_[[A],[B]]

The shorthand form is particularly useful in combination with the each shorthand, a way to introduce a
function of a single parameter named _ (for details, see Simplified declarations. Together, the two shorthands
simplify common higher-order functional expressions:

[Link]( {[a=1, b=1], [a=2, b=4]}, each [a] = [b])


// {[a=1, b=1]}

The above expression is equivalent to the following more cryptic looking longhand:

[Link]( {[a=1, b=1], [a=2, b=4]}, (_) => _[a] = _[b])


// {[a=1, b=1]}

Field access does not force the evaluation of fields other than the one(s) being accessed. For example:

[A=error "a", B=1, C=error "c"][B] // 1


[A=error "a", B=error "b"][B] // error "b"
The following holds when a field access operator x[y] , x[y]? , x[[y]] , or x[[y]]? is evaluated:
Errors raised during the evaluation of expression x are propagated.
Errors raised when evaluating field y are permanently associated with field y , then propagated. Any
future access to field y will raise the identical error.
The expression x produces a record or table value, or an error is raised.
If the identifier y names a field that does not exist in x , an error with reason code "[Link]"
is raised unless the optional operator form ...? is used, in which case the value null is returned.

No fields of x other than that named by y is evaluated during the process of field access.

Metadata operator
The metadata record for a value is amended using the meta operator ( x meta y ).
metadata-expression:
unary-expression
unary-expression meta unary-expression
The following example constructs a text value with a metadata record using the meta operator and then
accesses the metadata record of the resulting value using [Link] :

[Link]( "Mozart" meta [ Rating = 5 ] )


// [Rating = 5 ]
[Link]( "Mozart" meta [ Rating = 5 ] )[Rating]
// 5

The following holds when applying the metadata combining operator x meta y :
Errors raised when evaluating the x or y expressions are propagated.
The y expression must be a record, or an error with reason code "[Link]" is raised.
The resulting metadata record is x 's metadata record merged with y . (For the semantics of record
merge, see Record merge.)
The resulting value is the value from the x expression, without its metadata, with the newly computed
metadata record attached.
The standard library functions [Link] and [Link] can be used to remove all
metadata from a value and to replace a value's metadata (rather than merge metadata into possibly existing
metadata). The following expressions are equivalent:

x meta y
[Link](x, [Link](x) & y)
[Link](x) meta ([Link](x) & y)

Equality operators
The equality operator = is used to determine if two values are equal. The inequality operator <> is used to
determine if two values are not equal.
equality-expression:
relational-expression
relational-expression = equality-expression
relational-expression <> equality-expression

For example:

1 = 1 // true
1 = 2 // false
1 <> 1 // false
1 <> 2 // true
null = true // false
null = null // true

Metadata is not part of equality or inequality comparison. For example:

(1 meta [ a = 1 ]) = (1 meta [ a = 2 ]) // true


(1 meta [ a = 1 ]) = 1 // true

The following holds when applying the equality operators x = y and x <> y :
Errors raised when evaluating the x or y expressions are propagated.
The = operator has a result of true if the values are equal, and false otherwise.
The <> operator has a result of false if the values are equal, and true otherwise.
Metadata records are not included in the comparison.
If values produced by evaluating the x and y expressions are not the same kind of value, then the
values are not equal.
If the values produced by evaluating the x and y expression are the same kind of value, then there are
specific rules for determining if they are equal, as defined below.
The following is always true:

(x = y) = not (x <> y)

The equality operators are defined for the following types:


The null value is only equal to itself.

null = null // true


null = true // false
null = false // false

The logical values true and false are only equal to themselves. For example:

true = true // true


false = false // true
true = false // false
true = 1 // false

Numbers are compared using the specified precision:


If either number is #nan , then the numbers are not the same.
When neither number is #nan , then the numbers are compared using a bit-wise comparison of
the numeric value.
#nan is the only value that is not equal to itself.
For example:

1 = 1, // true
1.0 = 1 // true
2 = 1 // false
#nan = #nan // false
#nan <> #nan // true

Two durations are equal if they represent the same number of 100-nanosecond ticks.
Two times are equal if the magnitudes of their parts (hour, minute, second) are equal.
Two dates are equal if the magnitudes of their parts (year, month, day) are equal.
Two datetimes are equal if the magnitudes of their parts (year, month, day, hour, minute, second) are
equal.
Two datetimezones are equal if the corresponding UTC datetimes are equal. To arrive at the
corresponding UTC datetime, the hours/minutes offset is subtracted from the datetime component of the
datetimezone.
Two text values are equal if using an ordinal, case-sensitive, culture-insensitive comparison they have the
same length and equal characters at corresponding positions.
Two list values are equal if all of the following are true:
Both lists contain the same number of items.
The values of each positionally corresponding item in the lists are equal. This means that not only
do the lists need to contain equal items, the items need to be in the same order.
For example:

{1, 2} = {1, 2} // true


{2, 1} = {1, 2} // false
{1, 2, 3} = {1, 2} // false

Two records are equal if all of the following are true:


The number of fields is the same.
Each field name of one record is also present in the other record.
The value of each field of one record is equal to the like-named field in the other record.
For example:

[ A = 1, B = 2 ] = [ A = 1, B = 2 ] // true
[ B = 2, A = 1 ] = [ A = 1, B = 2 ] // true
[ A = 1, B = 2, C = 3 ] = [ A = 1, B = 2 ] // false
[ A = 1 ] = [ A = 1, B = 2 ] // false

Two tables are equal if all of the following are true:


The number of columns is the same.
Each column name in one table is also present in the other table.
The number of rows is the same.
Each row has equal values in corresponding cells.
For example:

#table({"A","B"},{{1,2}}) = #table({"A","B"},{{1,2}}) // true


#table({"A","B"},{{1,2}}) = #table({"X","Y"},{{1,2}}) // false
#table({"A","B"},{{1,2}}) = #table({"B","A"},{{2,1}}) // true

A function value is equal to itself, but may or may not be equal to another function value. If two function
values are considered equal, then they will behave identically when invoked.
Two given function values will always have the same equality relationship.
A type value is equal to itself, but may or may not be equal to another type value. If two type values are
considered equal, then they will behave identically when queried for conformance.
Two given type values will always have the same equality relationship.

Relational operators
The < , > , <= , and >= operators are called the relational operators.
relational-expression:
additive-expression
additive-expression < relational-expression
additive-expression > relational-expression
additive-expression <= _relational-expression
additive-expression >= relational-expression

These operators are used to determine the relative ordering relationship between two values, as shown in the
following table:

O P ERAT IO N RESULT

x < y true if x is less than y , false otherwise

x > y true if x is greater than y , false otherwise

x <= y true if x is less than or equal to y , false otherwise

x >= y true if x is greater than or equal to y , false


otherwise

For example:

0 <= 1 // true
null < 1 // null
null <= null // null
"ab" < "abc" // true
#nan >= #nan // false
#nan <= #nan // false

The following holds when evaluating an expression containing the relational operators:
Errors raised when evaluating the x or y operand expressions are propagated.
The values produced by evaluating both the x and y expressions must be a number, date, datetime,
datetimezone, duration, logical, null or time value. Otherwise, an error with reason code
"[Link]" is raised.

If either or both operands are null , the result is the null value.
If both operands are logical, the value true is considered to be greater than false .
If both operands are durations, then the values are compared according to the total number of 100-
nanosecond ticks they represent.
Two times are compared by comparing their hour parts and, if equal, their minute parts and, if equal,
their second parts.
Two dates are compared by comparing their year parts and, if equal, their month parts and, if equal, their
day parts.
Two datetimes are compared by comparing their year parts and, if equal, their month parts and, if equal,
their day parts and, if equal, their hour parts and, if equal, their minute parts and, if equal, their second
parts.
Two datetimezones are compared by normalizing them to UTC by subtracting their hour/minute offset
and then comparing their datetime components.
Two numbers x and y are compared according to the rules of the IEEE 754 standard:
If either operand is #nan , the result is false for all relational operators.
When neither operand is #nan , the operators compare the values of the two floatingpoint
operands with respect to the ordering
-∞ < -max < ... < -min < -0.0 = +0.0 < +min < ... < +max < +∞ where min and max are the
smallest and largest positive finite values that can be represented. The M names for -° and +° are
-#infinity and #infinity .

Notable effects of this ordering are:


Negative and positive zeros are considered equal.
A -#infinity value is considered less than all other number values, but equal to another
-#infinity .
A #infinity value is considered greater than all other number values, but equal to another
#infinity .

Conditional logical operators


The and and or operators are called the conditional logical operators.
logical-or-expression:
logical-and-expression
logical-and-expression or logical-or-expression
logical-and-expression:
is-expression
is-expression and logical-and-expression
The or operator returns true when at least one of its operands is true . The right operand is evaluated if and
only if the left operand is not true .
The and operator returns false when at least one of its operands is false . The right operand is evaluated if
and only if the left operand is not false .
Truth tables for the or and and operators are shown below, with the result of evaluating the left operand
expression on the vertical axis and the result of evaluating the right operand expression on the horizontal axis.

AND TRUE FALSE NULL ERROR

true true false null error

false false false false false

null null false null error

error error error error error

OR TRUE FALSE NULL ERROR

or true false null error

true true true true true

false true false null error

null true null null error

error error error error error

The following holds when evaluating an expression containing conditional logical operators:
Errors raised when evaluating the x or y expressions are propagated.
The conditional logical operators are defined over the types logical and null . If the operand values are
not of those types, an error with reason code "[Link]" is raised.
The result is a logical value.
In the expression x or y , the expression y will be evaluated if and only if x does not evaluate to
true .

In the expression x and y , the expression y will be evaluated if and only if x does not evaluate to
false .

The last two properties give the conditional logical operators their "conditional" qualification; properties also
referred to as "short-circuiting". These properties are useful to write compact guarded predicates. For example,
the following expressions are equivalent:

d <> 0 and n/d > 1 if d <> 0 then n/d > 1 else false

Arithmetic Operators
The + , - , * and / operators are the arithmetic operators.
additive-expression:
multiplicative-expression
additive-expression + multiplicative-expression
additive-expression - multiplicative-expression
multiplicative-expression:
metadata- expression
multiplicative-expression * metadata-expression
multiplicative-expression / metadata-expression
Precision
Numbers in M are stored using a variety of representations to retain as much information as possible about
numbers coming from a variety of sources. Numbers are only converted from one representation to another as
needed by operators applied to them. Two precisions are supported in M:

P REC ISIO N SEM A N T IC S

[Link] 128-bit decimal representation with a range of ±1.0 x 10-28


to ±7.9 x 1028 and 28-29 significant digits.

[Link] Scientific representation using mantissa and exponent;


conforms to the 64-bit binary double-precision IEEE 754
arithmetic standard IEEE 754-2008.

Arithmetic operations are performed by choosing a precision, converting both operands to that precision (if
necessary), then performing the actual operation, and finally returning a number in the chosen precision.
The built-in arithmetic operators ( + , - , * , / ) use Double Precision. Standard library functions ( [Link] ,
[Link] , [Link] , [Link] ) can be used to request these operations using a specific
precision model.
No numeric overflow is possible: #infinity or -#infinity represent values of magnitudes too large to
be represented.
No numeric underflow is possible: 0 and -0 represent values of magnitudes too small to be
represented.
The IEEE 754 special value #nan (NaN—Not a Number) is used to cover arithmetically invalid cases, such
as a division of zero by zero.
Conversion from Decimal to Double precision is performed by rounding decimal numbers to the nearest
equivalent double value.
Conversion from Double to Decimal precision is performed by rounding double numbers to the nearest
equivalent decimal value and, if necessary, overflowing to #infinity or -#infinity values.
Addition operator
The interpretation of the addition operator ( x + y ) is dependent on the kind of value of the evaluated
expressions x and y, as follows:

X Y RESULT IN T ERP RETAT IO N

type number type number type number Numeric sum

type number null null


X Y RESULT IN T ERP RETAT IO N

null type number null

type duration type duration type duration Numeric sum of


magnitudes

type duration null null

null type duration null

type datetime type duration type datetime Datetime offset by duration

type duration type datetime type datetime

type datetime null null

null type datetime null

In the table, type datetime stands for any of type date , type datetime , type datetimezone , or type time .
When adding a duration and a value of some type datetime, the resulting value is of that same type.
For other combinations of values than those listed in the table, an error with reason code "[Link]" is
raised. Each combination is covered in the following sections.
Errors raised when evaluating either operand are propagated.
Numeric sum
The sum of two numbers is computed using the addition operator, producing a number.
For example:

1 + 1 // 2
#nan + #infinity // #nan

The addition operator + over numbers uses Double Precision; the standard library function [Link] can be
used to specify Decimal Precision. The following holds when computing a sum of numbers:
The sum in Double Precision is computed according to the rules of 64-bit binary doubleprecision IEEE
754 arithmetic IEEE 754-2008. The following table lists the results of all possible combinations of nonzero
finite values, zeros, infinities, and NaN's. In the table, x and y are nonzero finite values, and z is the
result of x + y . If x and y have the same magnitude but opposite signs, z is positive zero. If x + y
is too large to be represented in the destination type, z is an infinity with the same sign as x + y .

+ Y +0 -0 +° -° NAN

x z x x +° -° NaN

+0 y +0 +0 +° -° NaN

-0 y +0 -0 +° -° NaN

+° +° +° +° +° NaN NaN
+ Y +0 -0 +° -° NAN

-° -° -° -° NaN -° NaN

NaN NaN NaN NaN NaN NaN NaN

The sum in Decimal Precision is computed without losing precision. The scale of the result is the larger of
the scales of the two operands.
Sum of durations
The sum of two durations is the duration representing the sum of the number of 100nanosecond ticks
represented by the durations. For example:

#duration(2,1,0,15.1) + #duration(0,1,30,45.3)
// #duration(2, 2, 31, 0.4)

Datetime offset by duration


A datetime x and a duration y may be added using x + y to compute a new datetime whose distance from
x on a linear timeline is exactly the magnitude of y . Here, datetime stands for any of Date , DateTime ,
DateTimeZone , or Time and a non-null result will be of the same type. The datetime offset by duration may be
computed as follows:
If the datetime's days since epoch value is specified, construct a new datetime with the following
information elements:
Calculate a new days since epoch equivalent to dividing the magnitude of y by the number of 100-
nanosecond ticks in a 24-hour period, truncating the decimal portion of the result, and adding this
value to the x's days since epoch.
Calculate a new ticks since midnight equivalent to adding the magnitude of y to the x's ticks since
midnight, modulo the number of 100-nanosecond ticks in a 24-hour period. If x does not specify a
value for ticks since midnight, a value of 0 is assumed.
Copy x's value for minutes offset from UTC unchanged.
If the datetime's days since epoch value is unspecified, construct a new datetime with the following
information elements specified:
Calculate a new ticks since midnight equivalent to adding the magnitude of y to the x's ticks since
midnight, modulo the number of 100-nanosecond ticks in a 24-hour period. If x does not specify a
value for ticks since midnight, a value of 0 is assumed.
Copy x's values for days since epoch and minutes offset from UTC unchanged.
The following examples show calculating the absolute temporal sum when the datetime specifies the days since
epoch:
#date(2010,05,20) + #duration(0,8,0,0)
//#datetime( 2010, 5, 20, 8, 0, 0 )
//2010-05-20T[Link]

#date(2010,01,31) + #duration(30,08,0,0)
//#datetime(2010, 3, 2, 8, 0, 0)
//2010-03-02T[Link]

#datetime(2010,05,20,12,00,00,-08) + #duration(0,04,30,00)
//#datetime(2010, 5, 20, 16, 30, 0, -8, 0)
//2010-05-20T[Link]-08:00

#datetime(2010,10,10,0,0,0,0) + #duration(1,0,0,0)
//#datetime(2010, 10, 11, 0, 0, 0, 0, 0)
//2010-10-11T[Link]+00:00

The following example shows calculating the datetime offset by duration for a given time:

#time(8,0,0) + #duration(30,5,0,0)
//#time(13, 0, 0)
//[Link]

Subtraction operator
The interpretation of the subtraction operator ( x - y ) is dependent on the kind of the value of the evaluated
expressions x and y , as follows:

X Y RESULT IN T ERP RETAT IO N

type number type number type number Numeric difference

type number null null

null type number null

type duration type duration type duration Numeric difference of


magnitudes

type duration null null

null type duration null

type datetime type datetime type duration Duration between


datetimes

type datetime type duration type datetime Datetime offset by negated


duration

type datetime null null

null type datetime null

In the table, type datetime stands for any of type date , type datetime , type datetimezone , or type time .
When subtracting a duration from a value of some type datetime, the resulting value is of that same type.
For other combinations of values than those listed in the table, an error with reason code "[Link]" is
raised. Each combination is covered in the following sections.
Errors raised when evaluating either operand are propagated.
Numeric difference
The difference between two numbers is computed using the subtraction operator, producing a number. For
example:

1 - 1 // 0
#nan - #infinity // #nan

The subtraction operator - over numbers uses Double Precision; the standard library function [Link]
can be used to specify Decimal Precision. The following holds when computing a difference of numbers:
The difference in Double Precision is computed according to the rules of 64-bit binary double-precision
IEEE 754 arithmetic IEEE 754-2008. The following table lists the results of all possible combinations of
nonzero finite values, zeros, infinities, and NaN's. In the table, x and y are nonzero finite values, and z
is the result of x - y . If x and y are equal, z is positive zero. If x - y is too large to be represented
in the destination type, z is an infinity with the same sign as x - y .

- Y +0 -0 +° -° NAN

x z x x -° +° NaN

+0 -y +0 +0 -° +° NaN

-0 -y -0 +0 -° +° NaN

+° +° +° +° NaN +° NaN

-° -° -° -° -° NaN NaN

NaN NaN NaN NaN NaN NaN NaN

The difference in Decimal Precision is computed without losing precision. The scale of the result is the
larger of the scales of the two operands.
Difference of durations
The difference of two durations is the duration representing the difference between the number of 100-
nanosecond ticks represented by each duration. For example:

#duration(1,2,30,0) - #duration(0,0,0,30.45)
// #duration(1, 2, 29, 29.55)

Datetime offset by negated duration


A datetime x and a duration y may be subtracted using x - y to compute a new datetime. Here, datetime
stands for any of date , datetime , datetimezone , or time . The resulting datetime has a distance from x on a
linear timeline that is exactly the magnitude of y , in the direction opposite the sign of y . Subtracting positive
durations yields results that are backwards in time relative to x , while subtracting negative values yields results
that are forwards in time.
#date(2010,05,20) - #duration(00,08,00,00)
//#datetime(2010, 5, 19, 16, 0, 0)
//2010-05-19T[Link]
#date(2010,01,31) - #duration( 30,08,00,00)
//#datetime(2009, 12, 31, 16, 0, 0)
//2009-12-31T[Link]

Duration between two datetimes


Two datetimes t and u may be subtracted using t - u to compute the duration between them. Here,
datetime stands for any of date , datetime , datetimezone , or time . The duration produced by subtracting u
from t must yield t when added to u .

#date(2010,01,31) - #date(2010,01,15)
// #duration(16,00,00,00)
// 16.[Link]

#date(2010,01,15)- #date(2010,01,31)
// #duration(-16,00,00,00)
// -16.[Link]

#datetime(2010,05,20,16,06,00,-08,00) -
#datetime(2008,12,15,04,19,19,03,00)
// #duration(521,22,46,41)
// 521.[Link]

Subtracting t - u when u > t results in a negative duration:

#time(01,30,00) - #time(08,00,00)
// #duration(0, -6, -30, 0)

The following holds when subtracting two datetimes using t - u :


u + (t - u) = t
Multiplication operator
The interpretation of the multiplication operator ( x * y ) is dependent on the kind of value of the evaluated
expressions x and y, as follows:

X Y RESULT IN T ERP RETAT IO N

type number type number type number Numeric product

type number null null

null type number null

type duration type number type duration Multiple of duration

type number type duration type duration Multiple of duration

type duration null null

null type duration null

For other combinations of values than those listed in the table, an error with reason code "[Link]" is
raised. Each combination is covered in the following sections.
Errors raised when evaluating either operand are propagated.
Numeric product
The product of two numbers is computed using the multiplication operator, producing a number. For example:

2 * 4 // 8
6 * null // null
#nan * #infinity // #nan

The multiplication operator * over numbers uses Double Precision; the standard library function
[Link] can be used to specify Decimal Precision. The following holds when computing a product of
numbers:
The product in Double Precision is computed according to the rules of 64-bit binary double-precision
IEEE 754 arithmetic IEEE 754-2008. The following table lists the results of all possible combinations of
nonzero finite values, zeros, infinities, and NaN's. In the table, x and y are positive finite values. z is
the result of x * y . If the result is too large for the destination type, z is infinity. If the result is too small
for the destination type, z is zero.

* +Y -Y +0 -0 +° -° NAN

+x +z -z +0 -0 +° -° NaN

-x -z +z -0 +0 -° +° NaN

+0 +0 -0 +0 -0 NaN NaN NaN

-0 -0 +0 -0 +0 NaN NaN NaN

+° +° -° NaN NaN +° -° NaN

-° -° +° NaN NaN -° +° NaN

NaN NaN NaN NaN NaN NaN NaN NaN

The product in Decimal Precision is computed without losing precision. The scale of the result is the
larger of the scales of the two operands.
Multiples of durations
The product of a duration and a number is the duration representing the number of 100nanosecond ticks
represented by the duration operand times the number operand. For example:

#duration(2,1,0,15.1) * 2
// #duration(4, 2, 0, 30.2)

Division operator
The interpretation of the division operator ( x / y ) is dependent on the kind of value of the evaluated
expressions x and y , as follows:
X Y RESULT IN T ERP RETAT IO N

type number type number type number Numeric quotient

type number null null

null type number null

type duration type number type duration Fraction of duration

type duration type duration type duration Numeric quotient of


durations

type duration null null

null type duration null

For other combinations of values than those listed in the table, an error with reason code "[Link]" is
raised. Each combination is covered in the following sections.
Errors raised when evaluating either operand are propagated.
Numeric quotient
The quotient of two numbers is computed using the division operator, producing a number. For example:

8 / 2 // 4
8 / 0 // #infinity
0 / 0 // #nan
0 / null // null
#nan / #infinity // #nan

The division operator / over numbers uses Double Precision; the standard library function [Link] can
be used to specify Decimal Precision. The following holds when computing a quotient of numbers:
The quotient in Double Precision is computed according to the rules of 64-bit binary double-precision
IEEE 754 arithmetic IEEE 754-2008. The following table lists the results of all possible combinations of
nonzero finite values, zeros, infinities, and NaN's. In the table, x and y are positive finite values. z is
the result of x / y . If the result is too large for the destination type, z is infinity. If the result is too small
for the destination type, z is zero.

/ +Y -Y +0 -0 +° -° NAN

+x +z -z +° -° +0 -0 NaN

-x -z +z -° +° -0 +0 NaN

+0 +0 -0 NaN NaN +0 -0 NaN

-0 -0 +0 NaN NaN -0 +0 NaN

+° +° -° +° -° NaN NaN NaN

-° -° +° -° +° NaN NaN NaN


/ +Y -Y +0 -0 +° -° NAN

NaN NaN NaN NaN NaN NaN NaN NaN

The sum in Decimal Precision is computed without losing precision. The scale of the result is the larger of
the scales of the two operands.
Quotient of durations
The quotient of two durations is the number representing the quotient of the number of 100nanosecond ticks
represented by the durations. For example:

#duration(2,0,0,0) / #duration(0,1,30,0)
// 32

Scaled durations
The quotient of a duration x and a number y is the duration representing the quotient of the number of 100-
nanosecond ticks represented by the duration x and the number y . For example:

#duration(2,0,0,0) / 32
// #duration(0,1,30,0)

Structure Combination
The combination operator ( x & y ) is defined over the following kinds of values:

X Y RESULT IN T ERP RETAT IO N

type text type text type text Concatenation

type text null null

null type text null

type date type time type datetime Merge

type date null null

null type time null

type list type list type list Concatenation

type record type record type record Merge

type table type table type table Concatenation

Concatenation
Two text, two list, or two table values can be concatenated using x & y .
The following example illustrates concatenating text values:

"AB" & "CDE" // "ABCDE"


The following example illustrates concatenating lists:

{1, 2} & {3} // {1, 2, 3}

The following holds when concatenating two values using x & y :


Errors raised when evaluating the x or y expressions are propagated.
No error is propagated if an item of either x or y contains an error.
The result of concatenating two text values is a text value that contains the value of x immediately
followed by y. If either of the operands is null and the other is a text value, the result is null.
The result of concatenating two lists is a list that contains all the items of x followed by all the items of
y .

The result of concatenating two tables is a table that has the union of the two operand table's columns.
The column ordering of x is preserved, followed by the columns only appearing in y , preserving their
relative ordering. For columns appearing only in one of the operands, null is used to fill in cell values
for the other operand.
Merge
Record merge
Two records can be merged using x & y , producing a record that includes fields from both x and y .
The following examples illustrate merging records:

[ x = 1 ] & [ y = 2 ] // [ x = 1, y = 2 ]
[ x = 1, y = 2 ] & [ x = 3, z = 4 ] // [ x = 3, y = 2, z = 4 ]

The following holds when merging two records using x + y :


Errors raised when evaluating the x or y expressions are propagated.
If a field appears in both x and y , the value from y is used.
The order of the fields in the resulting record is that of x , followed by fields in y that are not part of x ,
in the same order that they appear in y .
Merging records does not cause evaluation of the values.
No error is raised because a field contains an error.
The result is a record.
Date-time merge
A date x can be merged with a time y using x & y , producing a datetime that combines the parts from both
x and y .

The following example illustrates merging a date and a time:

#date(2013,02,26) & #time(09,17,00)


// #datetime(2013,02,26,09,17,00)

The following holds when merging two records using x + y :


Errors raised when evaluating the x or y expressions are propagated.
The result is a datetime.

Unary operators
The + , - , and not operators are unary operators.
unary-expression:
type-expression
+ unary expression
- unary expression
not unary expression

Unary plus operator


The unary plus operator ( +x ) is defined for the following kinds of values:

X RESULT IN T ERP RETAT IO N

type number type number Unary plus

type duration type duration Unary plus

null `null

For other values, an error with reason code "[Link]" is raised.


The unary plus operator allows a + sign to be applied to a number, datetime, or null value. The result is that
same value. For example:

+ - 1 // -1
+ + 1 // 1
+ #nan // #nan
+ #duration(0,1,30,0) // #duration(0,1,30,0)

The following holds when evaluating the unary plus operator +x :


Errors raised when evaluating x are propagated.
If the result of evaluating x is not a number value, then an error with reason code "[Link]" is
raised.
Unary minus operator
The unary minus operator ( -x ) is defined for the following kinds of values:

X RESULT IN T ERP RETAT IO N

type number type number Negation

type duration type duration Negation

null null

For other values, an error with reason code "[Link]" is raised.


The unary minus operator is used to change the sign of a number or duration. For example:
- (1 + 1) // -2
- - 1 // 1
- - - 1 // -1
- #nan // #nan
- #infinity // -#infinity
- #duration(1,0,0,0) // #duration(-1,0,0,0)
- #duration(0,1,30,0) // #duration(0,-1,-30,0)

The following holds when evaluating the unary minus operator -x :


Errors raised when evaluating x are propagated.
If the expression is a number, then the result is the number value from expression x with its sign
changed. If the value is NaN, then the result is also NaN.
Logical negation operator
The logical negation operator ( not ) is defined for the following kinds of values:

X RESULT IN T ERP RETAT IO N

type logical type logical Negation

null null

This operator computes the logical not operation on a given logical value. For example:

not true // false


not false // true
not (true and true) // false

The following holds when evaluating the logical negation operator not x :
Errors raised when evaluating x are propagated.
The value produced from evaluating expression x must be a logical value, or an error with reason code
"[Link]" must be raised. If the value is true , the result is false . If the operand is false , the
result is true .
The result is a logical value.

Type operators
The operators is and as are known as the type operators.
Type compatibility operator
The type compatibility operator x is y is defined for the following types of values:

X Y RESULT

type any nullable-primitive-type type logical

The expression x is y returns true if the ascribed type of x is compatible with y , and returns false if the
ascribed type of x is incompatible with y . y must be a nullable-primitivetype.
is-expression:
as-expression
is-expression is nullable-primitive-type
nullable-primitive-type:
nullable opt primitive-type

Type compatibility, as supported by the is operator, is a subset of general type compatibility and is defined
using the following rules:
If x is null then it is compatible iff y is a nullable type or the type any .
If x is non-null then if it is a compatible if the the primitive type of x is the same as y .
The following holds when evaluating the expression x is y :
An error raised when evaluating expression x is propagated.
Type assertion operator
The type assertion operator x as y is defined for the following types of values:

X Y RESULT

type any nullable-primitive-type type any

The expression x as y asserts that the value x is compatible with y as per the is operator. If it is not
compatible, an error is raised. y must be a nullable-primitive-type.
as-expression:
equality-expression
as-expression as nullable-primitive-type
The expression x as y is evaluated as follows:
A type compatibility check x is y is performed and the assertion returns x unchanged if that test
succeeds.
If the compatibility check fails, an error with reason code "[Link]" is raised.
Examples:

1 as number // 1
"A" as number // error
null as nullable number // null

The following holds when evaluating the expression x as y :


An error raised when evaluating expression x is propagated.
Coalesce operator
The coalesce operator ?? returns the result of its left operand if it is not null, otherwise it will return the result
of its right operand. The right operand is evaluated if and only if the left operand is null.
Let
9/13/2022 • 2 minutes to read

Let expression
A let expression can be used to capture a value from an intermediate calculation in a variable.
let-expression:
let variable-list in expression
variable-list:
variable
variable , variable-list
variable:
variable-name = expression
variable-name:
identifier
The following example shows intermediate results being calculated and stored in variables x , y , and z which
are then used in a subsequent calculation x + y + z :

let x = 1 + 1,
y = 2 + 2,
z = y + 1
in
x + y + z

The result of this expression is:

11 // (1 + 1) + (2 + 2) + (2 + 2 + 1)

The following holds when evaluating expressions within the let-expression:


The expressions in the variable list define a new scope containing the identifiers from the variable-list
production and must be present when evaluating the expressions within the variable-list productions.
Expressions within the variable-list may refer to one-another.
The expressions within the variable-list must be evaluated before the expression in the let-expression is
evaluated.
Unless the expressions in the variable-list are accessed, they must not be evaluated.
Errors that are raised during the evaluation of the expressions in the let-expression are propagated.
A let expression can be seen as syntactic sugar over an implicit record expression. The following expression is
equivalent to the example above:

[ x = 1 + 1,
y = 2 + 2,
z = y + 1,
result = x + y + z
][result]
Conditionals
9/13/2022 • 2 minutes to read

The if-expression selects from two expressions based on the value of a logical input value and evaluates only the
selected expression.
if-expression:
if if-condition then true-expression else false-expression
if-condition:
expression
true-expression:
expression
false-expression:
expression
The following are examples of if-expressions:

if 2 > 1 then 2 else 1 // 2


if 1 = 1 then "yes" else "no" // "yes"

The following holds when evaluating an if-expression:


If the value produced by evaluating the if-condition is not a logical value, then an error with reason code
"[Link]" is raised.

The true-expression is only evaluated if the if-condition evaluates to the value true .
The false-expression is only evaluated if the if-condition evaluates to the value false .
The result of the if-expression is the value of the true-expression if the if-condition is true , and the value
of the false-expression if the if-condition is false .
Errors raised during the evaluation of the if-condition, true-expression, or falseexpression are propagated.
Functions
9/13/2022 • 6 minutes to read

A function is a value that represents a mapping from a set of argument values to a single value. A function is
invoked by provided a set of input values (the argument values), and produces a single output value (the return
value).

Writing functions
Functions are written using a function-expression:
function-expression:
( parameter-listopt ) function-return-typeopt => function-body
function-body:
expression
parameter-list:
fixed-parameter-list
fixed-parameter-list , optional-parameter-list
optional-parameter-list
fixed-parameter-list:
parameter
parameter , fixed-parameter-list
parameter:
parameter-name parameter-typeopt
parameter-name:
identifier
parameter-type:
assertion
function-return-type:
assertion
assertion:
as nullable-primiitve-type
optional-parameter-list:
optional-parameter
optional-parameter , optional-parameter-list
optional-parameter:
optional parameter
nullable-primitve-type
nullable opt primitive-type_

The following is an example of a function that requires exactly two values x and y , and produces the result of
applying the + operator to those values. The x and y are parameters that are part of the formal-parameter-
list of the function, and the x + y is the function body:

(x, y) => x + y

The result of evaluating a function-expression is to produce a function value (not to evaluate the function-body).
As a convention in this document, function values (as opposed to function expressions) are shown with the
formal-parameter-list but with an ellipsis ( ... ) instead of the function-body. For example, once the function
expression above has been evaluated, it would be shown as the following function value:

(x, y) => ...

The following operators are defined for function values:

O P ERATO R RESULT

x = y Equal

x <> y Not equal

The native type of function values is a custom function type (derived from the intrinsic type function ) that lists
the parameter names and specifies all parameter types and the return type to be any . (See Function types for
details on function types.)

Invoking functions
The function-body of a function is executed by invoking the function value using an invokeexpression. Invoking
a function value means the function-body of the function value is evaluated and a value is returned or an error
is raised.
invoke-expression:
primary-expression ( argument-listopt )
argument-list:
expression-list
Each time a function value is invoked, a set of values are specified as an argument-list, called the arguments to
the function.
An argument-list is used to specify a fixed number of arguments directly as a list of expressions. The following
example defines a record with a function value in a field, and then invokes the function from another field of the
record:

[
MyFunction = (x, y, z) => x + y + z,
Result1 = MyFunction(1, 2, 3) // 6
]

The following holds when invoking a function:


The environment used to evaluate the function-body of the function includes a variable that corresponds
to each parameter, with the same name as the parameter. The value of each parameter corresponds to a
value constructed from the argument-list of the invokeexpression, as defined in Parameters.
All of the expressions corresponding to the function arguments are evaluated before the function-body is
evaluated.
Errors raised when evaluating the expressions in the expression-list or functionexpression are
propagated.
The number of arguments constructed from the argument-list must be compatible with the formal
parameters of the function, or an error is raised with reason code "[Link]" . The process for
determining compatibility is defined in Parameters.
Parameters
There are two kinds of formal parameters that may be present in a formal-parameter-list:
A required parameter indicates that an argument corresponding to the parameter must always be
specified when a function is invoked. Required parameters must be specified first in the formal-
parameter-list. The function in the following example defines required parameters x and y :

[
MyFunction = (x, y) => x + y,

Result1 = MyFunction(1, 1), // 2


Result2 = MyFunction(2, 2) // 4
]

An optional parameter indicates that an argument corresponding to the parameter may be specified
when a function is invoked, but is not required to be specified. If an argument that corresponds to an
optional parameter is not specified when the function is invoked, then the value null is used instead.
Optional parameters must appear after any required parameters in a formal-parameter-list. The function
in the following example defines a fixed parameter x and an optional parameter y :

[
MyFunction = fn(x, optional y) =>
if (y = null) x else x + y,
Result1 = MyFunction(1), // 1
Result2 = MyFunction(1, null), // 1
Result3 = MyFunction(2, 2), // 4
]

The number of arguments that are specified when a function is invoked must be compatible with the formal
parameter list. Compatibility of a set of arguments A for a function F is computed as follows:
Let the value N represent the number of arguments A constructed from the argumentlist. For example:

MyFunction() // N = 0
MyFunction(1) // N = 1
MyFunction(null) // N = 1
MyFunction(null, 2) // N = 2
MyFunction(1, 2, 3) // N = 3
MyFunction(1, 2, null) // N = 3
MyFunction(1, 2, {3, 4}) // N = 3

Let the value Required represent the number of fixed parameters of F and Optional the number of
optional parameters of F . For example:

() // Required = 0, Optional = 0
(x) // Required = 1, Optional = 0
(optional x) // Required = 0, Optional = 1
(x, optional y) // Required = 1, Optional = 1

Arguments A are compatible with function F if the following are true:


(N >= Fixed) and (N <= (Fixed + Optional))
The argument types are compatible with F 's corresponding parameter types
If the function has a declared return type, then the result value of the body of function F is compatible
with F 's return type if the following is true:
The value yielded by evaluating the function body with the supplied arguments for the function
parameters has a type that is compatible with the return type.
If the function body yields a value incompatible with the function's return type, an error with reason code
"[Link]" is raised.

Recursive functions
In order to write a function value that is recursive, it is necessary to use the scoping operator ( @ ) to reference
the function within its scope. For example, the following record contains a field that defines the Factorial
function, and another field that invokes it:

[
Factorial = (x) =>
if x = 0 then 1 else x * @Factorial(x - 1),
Result = Factorial(3) // 6
]

Similarly, mutually recursive functions can be written as long as each function that needs to be accessed has a
name. In the following example, part of the Factorial function has been refactored into a second Factorial2
function.

[
Factorial = (x) => if x = 0 then 1 else Factorial2(x),
Factorial2 = (x) => x * Factorial(x - 1),
Result = Factorial(3) // 6
]

Closures
A function can return another function as a value. This function can in turn depend on one or more parameters
to the original function. In the following example, the function associated with the field MyFunction returns a
function that returns the parameter specified to it:

[
MyFunction = (x) => () => x,
MyFunction1 = MyFunction(1),
MyFunction2 = MyFunction(2),
Result = MyFunction1() + MyFunction2() // 3
]

Each time the function is invoked, a new function value will be returned that maintains the value of the
parameter so that when it is invoked, the parameter value will be returned.

Functions and environments


In addition to parameters, the function-body of a function-expression can reference variables that are present in
the environment when the function is initialized. For example, the function defined by the field MyFunction
accesses the field C of the enclosing record A :
[
A =
[
MyFunction = () => C,
C = 1
],
B = A[MyFunction]() // 1
]

When MyFunction is invoked, it accesses the value of the variable C , even though it is being invoked from an
environment ( B ) that does not contain a variable C .

Simplified declarations
The each-expression is a syntactic shorthand for declaring untyped functions taking a single formal parameter
named _ (underscore).
each-expression:
each each-expression-body
each-expression-body:
function-body
Simplified declarations are commonly used to improve the readability of higher-order function invocation.
For example, the following pairs of declarations are semantically equivalent:

each _ + 1
(_) => _ + 1
each [A]
(_) => _[A]

[Link]( aTable, each [Weight] > 12 )


[Link]( aTable, (_) => _[Weight] > 12 )
Error Handling
9/13/2022 • 4 minutes to read

The result of evaluating an M expression produces one of the following outcomes:


A single value is produced.
An error is raised, indicating the process of evaluating the expression could not produce a value. An error
contains a single record value that can be used to provide additional information about what caused the
incomplete evaluation.
Errors can be raised from within an expression, and can be handled from within an expression.

Raising errors
The syntax for raising an error is as follows:
error-raising-expression:
error expression

Text values can be used as shorthand for error values. For example:

error "Hello, world" // error with message "Hello, world"

Full error values are records and can be constructed using the [Link] function:

error [Link]("FileNotFound", "File [Link] not found",


"[Link]")

The above expression is equivalent to:

error [
Reason = "FileNotFound",
Message = "File [Link] not found",
Detail = "[Link]"
]

Raising an error will cause the current expression evaluation to stop, and the expression evaluation stack will
unwind until one of the following occurs:
A record field, section member, or let variable—collectively: an entry—is reached. The entry is marked as
having an error, the error value is saved with that entry, and then propagated. Any subsequent access to
that entry will cause an identical error to be raised. Other entries of the record, section, or let expression
are not necessarily affected (unless they access an entry previously marked as having an error).
The top-level expression is reached. In this case, the result of evaluating the top-level expression is an
error instead of a value.
A try expression is reached. In this case, the error is captured and returned as a value.

Handling errors
An error-handling-expression is used to handle an error:
error-handling-expression:
try protected-expression otherwise-clauseopt
protected-expression:
expression
otherwise-clause:
otherwise default-expression
default-expression:
expression
The following holds when evaluating an error-handling-expression without an otherwiseclause:
If the evaluation of the protected-expression does not result in an error and produces a value x, the value
produced by the error-handling-expression is a record of the following form:

[ HasErrors = false, Value = x ]

If the evaluation of the protected-expression raises an error value e, the result of the error-handling-
expression is a record of the following form:

[ HasErrors = true, Error = e ]

The following holds when evaluating an error-handling-expression with an otherwiseclause:


The protected-expression must be evaluated before the otherwise-clause.
The otherwise-clause must be evaluated if and only if the evaluation of the protectedexpression raises an
error.
If the evaluation of the protected-expression raises an error, the value produced by the error-handling-
expression is the result of evaluating the otherwise-clause.
Errors raised during the evaluation of the otherwise-clause are propagated.
The following example illustrates an error-handling-expression in a case where no error is raised:

let
x = try "A"
in
if x[HasError] then x[Error] else x[Value]
// "A"

The following example shows raising an error and then handling it:

let
x = try error "A"
in
if x[HasError] then x[Error] else x[Value]
// [ Reason = "[Link]", Message = "A", Detail = null ]

An otherwise clause can be used to replace errors handled by a try expression with an alternative value:

try error "A" otherwise 1


// 1
If the otherwise clause also raises an error, then so does the entire try expression:

try error "A" otherwise error "B"


// error with message "B"

Errors in record and let initializers


The following example shows a record initializer with a field A that raises an error and is accessed by two other
fields B and C . Field B does not handle the error that is raised by A , but C does. The final field D does not
access A and so it is not affected by the error in A .

[
A = error "A",
B = A + 1,
C = let x =
try A in
if not x[HasError] then x[Value]
else x[Error],
D = 1 + 1
]

The result of evaluating the above expression is:

[
A = // error with message "A"
B = // error with message "A"
C = "A",
D = 2
]

Error handling in M should be performed close to the cause of errors to deal with the effects of lazy field
initialization and deferred closure evaluations. The following example shows an unsuccessful attempt at
handling an error using a try expression:

let
f = (x) => [ a = error "bad", b = x ],
g = try f(42) otherwise 123
in
g[a] // error "bad"

In this example, the definition g was meant to handle the error raised when calling f . However, the error is
raised by a field initializer that only runs when needed and thus after the record was returned from f and passed
through the try expression.

Not implemented error


While an expression is being developed, an author may want to leave out the implementation for some parts of
the expression, but may still want to be able to execute the expression. One way to handle this case is to raise an
error for the unimplemented parts. For example:
(x, y) =>
if x > y then
x - y
else
error [Link]("[Link]",
"Not Implemented")

The ellipsis symbol ( ... ) can be used as a shortcut for error .


not-implemented-expression:
...

For example, the following is equivalent to the previous example:

(x, y) => if x > y then x - y else ...


Sections
9/13/2022 • 4 minutes to read

A section-document is an M program that consists of multiple named expressions.


section-document:
section
section:
literal-attributesopt section section-name ; section-membersopt
section-name:
identifier
section-members:
section-member section-membersopt
section-member:
literal-attributesopt shared opt section-member-name = expression ;
section-member-name:
identifier
In M, a section is an organizational concept that allows related expressions to be named and grouped within a
document. Each section has a section-name, which identifies the section and qualifies the names of the section-
members declared within the section. A sectionmember consists of a member-name and an expression. Section
member expressions may refer to other section members within the same section directly by member name.
The following example shows a section-document:

section Section1;

A = 1; //1
B = 2; //2
C = A + B; //3

Section member expressions may refer to section members located in other sections by means of a section-
access-expression, which qualifies a section member name with the name of the containing section.
section-access-expression:
identifier ! identifier
The following example shows a set of two documents containing sections that are mutually referential:

section Section1;
A = "Hello"; //"Hello"
B = 1 + Section2!A; //3

section Section2;
A = 2; //2
B = Section1!A & " world!"; /"Hello, world"

Section members may optionally be declared as shared , which omits the requirement to use a section-access-
expression when referring to shared members outside of the containing section. Shared members in external
sections may be referred to by their unqualified member name so long as no member of the same name is
declared in the referring section and no other section has a like-named shared member.
The following example illustrates the behavior of shared members when used across sections within the same
set of documents:

section Section1;
shared A = 1; // 1

section Section2;
B = A + 2; // 3 (refers to shared A from Section1)

section Section3;
A = "Hello"; // "Hello"
B = A + " world"; // "Hello world" (refers to local A)
C = Section1!A + 2; // 3

Defining a shared member with the same name in different sections will produce a valid global environment,
however accessing the shared member will raise an error when accessed.

section Section1;
shared A = 1;

section Section2;
shared A = "Hello";

section Section3;
B = A; //Error: shared member A has multiple definitions

The following holds when evaluating a set of section-documents:


Each section-name must be unique in the global environment.
Within a section, each section-member must have a unique section-member-name.
Shared section members with more than one definition raise an error when the shared member is
accessed.
The expression component of a section-member must not be evaluated before the section member is
accessed.
Errors raised while the expression component of a section-member is evaluated are associated with that
section member before propagating outward and then re-raised each time the section member is
accessed.

Document Linking
A set of M section documents can be linked into an opaque record value that has one field per shared member
of the section documents. If shared members have ambiguous names, an error is raised.
The resulting record value fully closes over the global environment in which the link process was performed.
Such records are, therefore, suitable components to compose M documents from other (linked) sets of M
documents. There are no opportunities for naming conflicts.
The standard library functions [Link] can be used to retrieve such "embedded" record values that
correspond to reused M components.

Document Introspection
M provides programmatic access to the global environment by means of the #sections and #shared
keywords.
#sections
The #sections intrinsic variable returns all sections within the global environment as a record. This record is
keyed by section name and each value is a record representation of the corresponding section indexed by
section member name.
The following example shows a document consisting of two sections and the record produced by evaluating the
#sections intrinsic variable within the context of that document:

section Section1;
A = 1;
B = 2;

section Section2;
C = "Hello";
D = "world";

#sections
//[
// Section1 = [ A = 1, B = 2],
// Section2 = [ C = "Hello", D = "world" ]
//]

The following holds when evaluating #sections :


The #sections intrinsic variable preserves the evaluation state of all section member expressions within the
document.
The #sections intrinsic variable does not force the evaluation of any unevaluated section members.
#shared
The #shared intrinsic variable returns a record containing the names and values of all shared section members
currently in scope.
The following example shows a document with two shared members and the corresponding record produced
by evaluating the #shared intrinsic variable within the context of that document:

section Section1;
shared A = 1;
B = 2;

Section Section2;
C = "Hello";
shared D = "world";

//[
// A = 1,
// D = "world"
//]

The following holds when evaluating #shared :


The #shared intrinsic variable preserves the evaluation state of all shared member expressions within
the document.
The #shared intrinsic variable does not force the evaluation of any unevaluated section members.
Consolidated Grammar
9/13/2022 • 5 minutes to read

Lexical grammar
lexical-unit:
lexical-elementsopt
lexical-elements:
lexical-element lexical-elementsopt
lexical-element:
whitespace
token comment
White space
whitespace:
Any character with Unicode class Zs
Horizontal tab character ( U+0009 )
Vertical tab character ( U+000B )
Form feed character ( U+000C )
Carriage return character ( U+000D ) followed by line feed character ( U+000A ) new-line-character
new-line-character:
Carriage return character ( U+000D )
Line feed character ( U+000A )
Next line character ( U+0085 )
Line separator character ( U+2028 )
Paragraph separator character ( U+2029 )
Comment
comment:
single-line-comment
delimited-comment
single-line-comment:
// single-line-comment-charactersopt
single-line-comment-characters:
single-line-comment-character single-line-comment-charactersopt
single-line-comment-character:
Any Unicode character except a new-line-character
delimited-comment:
/* delimited-comment-textopt asterisks /
delimited-comment-text:
delimited-comment-section delimited-comment-textopt
delimited-comment-section:
/
asterisksopt not-slash-or-asterisk
asterisks:
* asterisksopt
not-slash-or-asterisk:
Any Unicode character except * or /
Tokens
token:
identifier
keyword
literal
operator-or-punctuator
Character escape sequences
character-escape-sequence:
#( escape-sequence-list )
escape-sequence-list:
single-escape-sequence
escape-sequence-list , single-escape-sequence
single-escape-sequence:
long-unicode-escape-sequence
short-unicode-escape-sequence
control-character-escape-sequence
escape-escape
long-unicode-escape-sequence:
hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit hex-digit
short-unicode-escape-sequence:
hex-digit hex-digit hex-digit hex-digit
control-character-escape-sequence:
control-character
control-character:
cr
lf
tab
escape-escape:
#

Literals
literal:
logical-literal
number-literal
text-literal
null-literal
verbatim-literal
logical-literal:
true
false
number-literal:
decimal-number-literal
hexadecimal-number-literal
decimal-digits:
decimal-digit decimal-digitsopt
decimal-digit: one of
0 1 2 3 4 5 6 7 8 9
hexadecimal-number-literal:
0x hex-digits
0X hex-digits
hex-digits:
hex-digit hex-digitsopt
hex-digit: one of
0 1 2 3 4 5 6 7 8 9 A B C D E F a b c d e f
decimal-number-literal:
decimal-digits . decimal-digits exponent-partopt
. decimal-digits exponent-partopt
decimal-digits exponent-partopt
exponent-part:
e signopt decimal-digits
E signopt decimal-digits
sign: one of
+ -
text-literal:
" text-literal-charactersopt "
text-literal-characters:
text-literal-character text-literal-charactersopt
text-literal-character:
single-text-character
character-escape-sequence
double-quote-escape-sequence
single-text-character:
Any character except " ( U+0022 ) or # ( U+0023 ) followed by ( ( U+0028 )
double-quote-escape-sequence:
"" ( U+0022 , U+0022 )
null-literal:
null
verbatim-literal:
#!" text-literal-charactersopt "

Identifiers
identifier:
regular-identifier
quoted-identifier
regular-identifier:
available-identifier
available-identifier dot-character regular-identifier
available-identifier:
A keyword-or-identifier that is not a keyword
keyword-or-identifier:
letter-character
underscore-character
identifier-start-character identifier-part-characters
identifier-start-character:
letter-character
underscore-character
identifier-part-characters:
identifier-part-character identifier-part-charactersopt
identifier-part-character:
letter-character
decimal-digit-character
underscore-character
connecting-character
combining-character
formatting-character
generalized-identifier:
generalized-identifier-part
generalized-identifier separated only by blanks ( U+0020 ) generalized-identifier-part
generalized-identifier-part:
generalized-identifier-segment
decimal-digit-character generalized-identifier-segment
generalized-identifier-segment:
keyword-or-identifier
keyword-or-identifier dot-character keyword-or-identifier
dot-character:
. ( U+002E )
underscore-character:
_ ( U+005F )
letter-character:_
A Unicode character of classes Lu, Ll, Lt, Lm, Lo, or Nl
combining-character:
A Unicode character of classes Mn or Mc
decimal-digit-character:
A Unicode character of the class Nd
connecting-character:
A Unicode character of the class Pc
formatting-character:
A Unicode character of the class Cf
quoted-identifier:
#" text-literal-charactersopt "

Keywords and predefined identifiers


Predefined identifiers and keywords cannot be redefined. A quoted identifier can be used to handle identifiers
that would otherwise collide with predefined identifiers or keywords.
keyword: one of
and as each else error false if in is let meta not null or otherwise
section shared then true try type #binary #date #datetime
#datetimezone #duration #infinity #nan #sections #shared #table #time

Operators and punctuators


operator-or-punctuator: one of
, ; = < <= > >= <> + - * / & ( ) [ ] { } @ ? ?? => .. ...

Syntactic grammar
Documents
document:
section-document
expression-document
Section Documents
section-document:
section
section:
literal-attributesopt section section-name ; section-membersopt
section-name:
identifier
section-members:
section-member section-membersopt
section-member:
literal-attributesopt sharedopt section-member-name = expression ;
section-member-name:
identifier
Expression Documents
Expressions
expression-document:
expression
expression:
logical-or-expression
each-expression
function-expression
let-expression
if-expression
error-raising-expression
error-handling-expression
Logical expressions
logical-or-expression:
logical-and-expression
logical-and-expression or logical-or-expression
logical-and-expression:
is-expression
logical-and-expression and is-expression
Is expression
is-expression:
as-expression
is-expression is nullable-primitive-type
nullable-primitive-type:
nullable opt primitive-type

As expression
as-expression:
equality-expression
as-expression as nullable-primitive-type
Equality expression
equality-expression:
relational-expression
relational-expression = equality-expression
relational-expression <> equality-expression

Relational expression
relational-expression:
additive-expression
additive-expression < relational-expression
additive-expression > relational-expression
additive-expression <= relational-expression
additive-expression >= relational-expression
Arithmetic expressions
additive-expression:
multiplicative-expression
multiplicative-expression + additive-expression
multiplicative-expression - additive-expression
multiplicative-expression & _additive-expression
multiplicative-expression:
metadata-expression
metadata-expression * multiplicative-expression
metadata-expression / multiplicative-expression
Metadata expression
metadata-expression:
unary-expression
unary-expression meta unary-expression
Unary expression
unary-expression:
type-expression
+ unary-expression
- unary-expression
not unary-expression

Primary expression
primary-expression:
literal-expression
list-expression
record-expression
identifier-expression
section-access-expression
parenthesized-expression
field-access-expression
item-access-expression
invoke-expression
not-implemented-expression
Literal expression
literal-expression:
literal
Identifier expression
identifier-expression:
identifier-reference
identifier-reference:
exclusive-identifier-reference
inclusive-identifier-reference
exclusive-identifier-reference:
identifier
inclusive-identifier-reference:
@ identifier

Section-access expression
section-access-expression:
identifier ! identifier
Parenthesized expression
parenthesized-expression:
( expression )

Not-implemented expression
not-implemented-expression:
...

Invoke expression
invoke-expression:
primary-expression ( argument-listopt )
argument-list:
expression
expression , argument-list
List expression
list-expression:
{ item-listopt }
item-list:
item
item , item-list
item:
expression
expression .. expression
Record expression
record-expression:
[ field-listopt ]
field-list:
field
field , field-list
field:
field-name = expression
field-name:
generalized-identifier
quoted-identifier
Item access expression
item-access-expression:
item-selection
optional-item-selection
item-selection:
primary-expression { item-selector }
optional-item-selection:
primary-expression { item-selector } ?
item-selector:
expression
Field access expressions
field-access-expression:
field-selection
implicit-target-field-selection
projection
implicit-target-projection
field-selection:
primary-expression field-selector
field-selector:
required-field-selector
optional-field-selector
required-field-selector:
[ field-name ]
optional-field-selector:
[ field-name ] ?
field-name:
generalized-identifier
quoted-identifier
implicit-target-field-selection:
field-selector
projection:
primary-expression required-projection
primary-expression optional-projection
required-projection:
[ required-selector-list ]
optional-projection:
[ required-selector-list ] ?
required-selector-list:
required-field-selector
required-field-selector , required-selector-list
implicit-target-projection:
required-projection
optional-projection
Function expression
function-expression:
( parameter-listopt ) return-typeopt => function-body
function-body:
expression
parameter-list:
fixed-parameter-list
fixed-parameter-list , optional-parameter-list
optional-parameter-list
fixed-parameter-list:
parameter
parameter , fixed-parameter-list
parameter:
parameter-name parameter-typeopt
parameter-name:
identifier
parameter-type:
assertion
return-type:
assertion
assertion:
as nullable-primitive-type
optional-parameter-list:
optional-parameter
optional-parameter , optional-parameter-list
optional-parameter:
optional parameter
Each expression
each-expression:
each each-expression-body
each-expression-body:
function-body
Let expression
let-expression:
let variable-list in expression
variable-list:
variable
variable , variable-list
variable:
variable-name = expression
variable-name:
identifier
If expression
if-expression:
if if-condition then true-expression else false-expression
if-condition:
expression
true-expression:
expression
false-expression:
expression
Type expression
type-expression:
primary-expression
type primary-type
type:
parenthesized-expression
primary-type
primary-type:
primitive-type
record-type
list-type
function-type
table-type
nullable-type
primitive-type: one of
any anynonnull binary date datetime datetimezone duration function
list logical none null number record table text time type
record-type:
[ open-record-marker ]
[ field-specification-listopt ]
[ field-specification-list , open-record-marker ]
field-specification-list:
field-specification
field-specification , field-specification-list
field-specification:
optional opt field-name field-type-specificationopt
field-type-specification:
= field-type
field-type:
type
open-record-marker:
...
list-type:
{ item-type }
item-type:
type
function-type:
function ( parameter-specification-listopt ) return-type
parameter-specification-list:
required-parameter-specification-list
required-parameter-specification-list , optional-parameter-specification-list
optional-parameter-specification-list
required-parameter-specification-list:
required-parameter-specification
required-parameter-specification , required-parameter-specification-list
required-parameter-specification:
parameter-specification
optional-parameter-specification-list:
optional-parameter-specification
optional-parameter-specification , optional-parameter-specification-list
optional-parameter-specification:
optional parameter-specification
parameter-specification:
parameter-name parameter-type
table-type:
table row-type
row-type:
[ field-specification-listopt ]
nullable-type:
nullable type

Error raising expression


error-raising-expression:
error expression_

Error handling expression


error-handling-expression:
try protected-expression otherwise-clauseopt
protected-expression:
expression
otherwise-clause:
otherwise default-expression
default-expression:
expression
Literal Attributes
literal-attributes:
record-literal
record-literal:
[ literal-field-listopt ]
literal-field-list:
literal-field
literal-field , literal-field-list
literal-field:
field-name = any-literal
list-literal:
{ literal-item-listopt }
literal-item-list:
any-literal
any-literal , literal-item-list
any-literal:
record-literal
list-literal
logical-literal
number-literal
text-literal
null-literal
Types in the Power Query M formula language
9/13/2022 • 8 minutes to read

The Power Query M Formula Language is a useful and expressive data mashup language. But it does have some
limitations. For example, there is no strong enforcement of the type system. In some cases, a more rigorous
validation is needed. Fortunately, M provides a built-in library with support for types to make stronger
validation feasible.
Developers should have a thorough understanding of the type system in-order to do this with any generality.
And, while the Power Query M language specification explains the type system well, it does leave a few
surprises. For example, validation of function instances requires a way to compare types for compatibility.
By exploring the M type system more carefully, many of these issues can be clarified, and developers will be
empowered to craft the solutions they need.
Knowledge of predicate calculus and naïve set theory should be adequate to understand the notation used.

PRELIMINARIES
(1) B := { true; false }
B is the typical set of Boolean values
(2) N := { valid M identifiers }
N is the set of all valid names in M. This is defined elsewhere.
(3) P := B, T
P is the set of function parameters. Each one is possibly optional, and has a type. Parameter names are
irrelevant.
(4) Pn := ⋃0≤i≤n i, Pi
Pn is the set of all ordered sequences of n function parameters.
(5) P* := ⋃0≤i≤° Pi
P* is the set of all possible sequences of function parameters, from length 0 on up.
(6) F := B, N, T
F is the set of all record fields. Each field is possibly optional, has a name, and a type.
(7) Fn := ∏0≤i≤n F
Fn is the set of all sets of n record fields.
(8) F* := ( ⋃0≤i≤° Fi ) ∖ { F | b1, n1, t1 , b2, n2, t2 ∈ F ⋀ n1 = n2 }
F* is the set of all sets (of any length) of record fields, except for the sets where more than one field has the same
name.
(9) C := N,T
C is the set of column types, for tables. Each column has a name and a type.
(10) Cn ⊂ ⋃0≤i≤n i, C
Cn is the set of all ordered sequences of n column types.
(11) C* := ( ⋃0≤i≤° Ci ) ∖ { Cm | a, n1, t1 , b, n2, t2 ∈ Cm ⋀ n1 = n2 }
C* is the set of all combinations (of any length) of column types, except for those where more than one column
has the same name.
M TYPES
(12) TF := P, P*
A Function Type consists of a return type, and an ordered list of zero-or-more function parameters.
(13) TL :=〖T〗
A List type is indicated by a given type (called the "item type") wrapped in curly braces. Since curly braces are
used in the metalanguage, 〖 〗 brackets are used in this document.
(14) TR := B, F*
A Record Type has a flag indicating whether it's "open", and zero-or-more unordered record fields.
(15) TRo := true, F
(16) TR• := false, F
TRo and TR• are notational shortcuts for open and closed record types, respectively.
(17) TT := C*
A Table Type is an ordered sequence of zero-or-more column types, where there are no name collisions.
(18) TP := { any; none; null; logical; number; time; date; datetime; datetimezone; duration; text; binary; type; list;
record; table; function; anynonnull }
A Primitive Type is one from this list of M keywords.
(19) TN := { tn , u ∈ T | tn = u+null } = nullable t
Any type can additionally be marked as being nullable, by using the "nullable" keyword.
(20) T := TF ∪ TL ∪ TR ∪ TT ∪ TP ∪ TN
The set of all M types is the union of these six sets of types:
Function Types, List Types, Record Types, Table Types, Primitive Types, and Nullable Types.

FUNCTIONS
One function needs to be defined: NonNullable : T ← T
This function takes a type, and returns a type that is equivalent except it does not conform with the null value.

IDENTITIES
Some identities are needed to define some special cases, and may also help elucidate the above.
(21) nullable any = any
(22) nullable anynonnull = any
(23) nullable null = null
(24) nullable none = null
(25) nullable nullable t ∈ T = nullable t
(26) NonNullable(nullable t ∈ T) = NonNullable(t)
(27) NonNullable(any) = anynonnull

TYPE COMPATIBILITY
As defined elsewhere, an M type is compatable with another M type if and only if all values that conform to the
first type also conform to the second type.
Here is defined a compatibility relation that does not depend on conforming values, and is based on the
properties of the types themselves. It is anticipated that this relation, as defined in this document, is completely
equivalent to the original semantic definition.
The "is compatible with" relation : ≤ : B ← T × T
In the below section, a lowercase t will always represent an M Type, an element of T.
A Φ will represent a subset of F*, or of C*.
(28) t ≤ t
This relation is reflexive.
(29) ta ≤ tb ∧ tb ≤ tc → ta ≤ tc
This relation is transitive.
(30) none ≤ t ≤ any
M types form a lattice over this relation; none is the bottom, and any is the top.
(31) ta, tb ∈ TN ∧ ta ≤ ta → NonNullable(ta) ≤ NonNullable(tb)
If two types are compatible, then the NonNullable equivalents are also compatible.
(32) null ≤ t ∈ TN
The primitive type null is compatible with all nullable types.
(33) t ∉ TN ≤ anynonnull
All nonnullable types are compatible with anynonnull.
(34) NonNullable(t) ≤ t
A NonNullible type is compatible with the nullable equivalent.
(35) t ∈ TF → t ≤ function
All function types are compatible with function.
(36) t ∈ TL → t ≤ list
All list types are compatible with list.
(37) t ∈ TR → t ≤ record
All record types are compatible with record.
(38) t ∈ TT → t ≤ table
All table types are compatible with table.
(39) ta ≤ tb ↔ 〖ta〗≤ 〖tb〗
A list type is compaible with another list type if the item types are compatible, and vice-versa.
(40) ta ∈ TF = pa, p* , tb ∈ TF = pb, p* ∧ pa ≤ pb → ta ≤ tb
A function type is compatible with another function type if the return types are compatible, and the parameter
lists are identical.
(41) ta ∈ TRo, tb ∈ TR• → ta ≰ tb
An open record type is never compatible with a closed record type.
(42) ta ∈ TR• = false, Φ , tb ∈ TRo = true, Φ → ta ≤ tb
A closed record type is compatible with an otherwise identical open record type.
(43) ta ∈ TRo = true, (Φ, true, n, any ) , tb ∈ TRo = true, Φ → ta ≤ tb ∧ tb ≤ ta
An optional field with the type any may be ignored when comparing two open record types.
(44) ta ∈ TR = b, (Φ, β, n, ua ) , tb ∈ TR = b, (Φ, β, n, ub ) ∧ ua ≤ ub → ta ≤ tb
Two record types that differ only by one field are compatible if the name and optionality of the field are identical,
and the types of said field are compatible.
(45) ta ∈ TR = b, (Φ, false, n, u ) , tb ∈ TR = b, (Φ, true, n, u ) → ta ≤ tb
A record type with a non-optional field is compatible with a record type identical but for that field being
optional.
o o
(46) ta ∈ TRo = true, (Φ, b, n, u ) , tb ∈ TRo = true, Φ → ta ≤ tb
An open record type is compatible with another open record type with one fewer field.
(47) ta ∈ TT = (Φ, i, n, ua ), tb ∈ TT = (Φ, i, n, ub ) ∧ ua ≤ ub → ta ≤ tb
A table type is compatible with a second table type, which is identical but for one column having a differing type,
when the types for that column are compatible.

REFERENCES
Microsoft Corporation (2015 August)
Microsoft Power Query for Excel Formula Language Specification [PDF]
Retrieved from [Link]
Microsoft Corporation (n.d.)
Power Query M function reference [web page]
Retrieved from [Link]
Expressions, values, and let expression
9/13/2022 • 5 minutes to read

A Power Query M formula language query is composed of formula expression steps that create a mashup
query. A formula expression can be evaluated (computed), yielding a value. The let expression encapsulates a
set of values to be computed, assigned names, and then used in a subsequent expression that follows the in
statement. For example, a let expression could contain a Source variable that equals the value of [Link]()
and yields a text value in proper case.

Let expression
let
Source = [Link]("hello world")
in
Source

In the example above, [Link]("hello world") is evaluated to "Hello World".


The next sections describe value types in the language.

Primitive value
A primitive value is single-part value, such as a number, logical, text, or null. A null value can be used to indicate
the absence of any data.

TYPE EXA M P L E VA L UE

Binary 00 00 00 02 // number of points (2)

Date 5/23/2015

DateTime 5/23/2015 [Link] AM

DateTimeZone 5/23/2015 [Link] AM -08:00

Duration [Link]

Logical true and false

Null null

Number 0, 1, -1, 1.5, and 2.3e-5

Text "abc"

Time [Link] PM

Function value
A Function is a value that, when invoked with arguments, produces a new value. Functions are written by listing
the function’s parameters in parentheses, followed by the goes-to symbol =>, followed by the expression
defining the function. For example, to create a function called “MyFunction” that has two parameters and
performs a calculation on parameter1 and parameter2:

let
MyFunction = (parameter1, parameter2) => (parameter1 + parameter2) / 2
in
MyFunction

Calling the MyFunction() returns the result:

let
Source = MyFunction(2, 4)
in
Source

This code produces the value of 3.

Structured data values


The M language supports the following structured data values:
List
Record
Table
Additional structured data examples

NOTE
Structured data can contain any M value. To see a couple of examples, see Additional structured data examples.

List
A List is a zero-based ordered sequence of values enclosed in curly brace characters { }. The curly brace
characters { } are also used to retrieve an item from a List by index position. See [List value](#_List_value).

NOTE
Power Query M supports an infinite list size, but if a list is written as a literal, the list has a fixed length. For example, {1, 2,
3} has a fixed length of 3.

The following are some List examples.

VA L UE TYPE

{123, true, "A"} List containing a number, a logical, and text.

{1, 2, 3} List of numbers

{ List of List of numbers


{1, 2, 3},
{4, 5, 6}
}
VA L UE TYPE

{ List of Records
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}

{123, true, "A"}{0} Get the value of the first item in a List. This expression
returns the value 123.

{ Get the value of the second item from the first List element.
{1, 2, 3}, This expression returns the value 2.
{4, 5, 6}
}{0}{1}

Record
A Record is a set of fields. A field is a name/value pair where the name is a text value that is unique within the
field’s record. The syntax for record values allows the names to be written without quotes, a form also referred
to as identifiers . An identifier can take the following two forms:
identifier_name such as OrderID.
#"identifier name" such as #"Today's data is: ".
The following is a record containing fields named "OrderID", "CustomerID", "Item", and "Price" with values 1, 1,
"Fishing rod", and 100.00. Square brace characters [ ] denote the beginning and end of a record expression, and
are used to get a field value from a record. The follow examples show a record and how to get the Item field
value.
Here's an example record:

let Source =
[
OrderID = 1,
CustomerID = 1,
Item = "Fishing rod",
Price = 100.00
]
in Source

To get the value of an Item, you use square brackets as Source[Item]:

let Source =
[
OrderID = 1,
CustomerID = 1,
Item = "Fishing rod",
Price = 100.00
]
in Source[Item] //equals "Fishing rod"

Table
A Table is a set of values organized into named columns and rows. The column type can be implicit or explicit.
You can use #table to create a list of column names and list of rows. A Table of values is a List in a List . The curly
brace characters { } are also used to retrieve a row from a Table by index position (see Example 3 – Get a row
from a table by index position).
Example 1 - Create a table with implicit column types
let
Source = #table(
{"OrderID", "CustomerID", "Item", "Price"},
{
{1, 1, "Fishing rod", 100.00},
{2, 1, "1 lb. worms", 5.00}
})
in
Source

Example 2 – Create a table with explicit column types

let
Source = #table(
type table [OrderID = number, CustomerID = number, Item = text, Price = number],
{
{1, 1, "Fishing rod", 100.00},
{2, 1, "1 lb. worms", 5.00}
}
)
in
Source

Both of the examples above creates a table with the following shape:

O RDERID C USTO M ERID IT EM P RIC E

1 1 Fishing rod 100.00

2 1 1 lb. worms 5.00

Example 3 – Get a row from a table by index position

let
Source = #table(
type table [OrderID = number, CustomerID = number, Item = text, Price = number],
{
{1, 1, "Fishing rod", 100.00},
{2, 1, "1 lb. worms", 5.00}
}
)
in
Source{1}

This expression returns the follow record:

F IEL D VA L UE

OrderID 2

CustomerID 1

Item 1 lb. worms

Price 5

Additional structured data examples


Structured data can contain any M value. Here are some examples:
Example 1 - List with [Primitive](#_Primitive_value_1) values, [Function ](#_Function_value), and [Record](#_Record_value)

let
Source =
{
1,
"Bob",
[Link]([Link](), "yyyy-MM-dd"),
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]
}
in
Source

Evaluating this expression can be visualized as:

Example 2 - Record containing Primitive values and nested Records

let
Source = [CustomerID = 1, Name = "Bob", Phone = "123-4567", Orders =
{
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0]
}]
in
Source

Evaluating this expression can be visualized as:


NOTE
Although many values can be written literally as an expression, a value is not an expression. For example, the expression 1
evaluates to the value 1; the expression 1+1 evaluates to the value 2. This distinction is subtle, but important. Expressions
are recipes for evaluation; values are the results of evaluation.

If expression
The if expression selects between two expressions based on a logical condition. For example:

if 2 > 1 then
2 + 2
else
1 + 1

The first expression (2 + 2) is selected if the logical expression (2 > 1) is true, and the second expression (1 + 1)
is selected if it is false. The selected expression (in this case 2 + 2) is evaluated and becomes the result of the if
expression (4).
Comments
9/13/2022 • 2 minutes to read

You can add comments to your code with single-line comments // or multi-line comments that begin with /*
and end with */ .
Example - Single-line comment

let
//Convert to proper case.
Source = [Link]("hello world")
in
Source

Example - Multi-line comment

/* Capitalize each word in the Item column in the Orders table. [Link]
is evaluated for each Item in each table row. */
let
Orders = [Link]({
[OrderID = 1, CustomerID = 1, Item = "fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "fishing net", Price = 25.0]}),
#"Capitalized Each Word" = [Link](Orders, {"Item", [Link]})
in
#"Capitalized Each Word"
Evaluation model
9/13/2022 • 2 minutes to read

The evaluation model of the Power Query M formula language is modeled after the evaluation model
commonly found in spreadsheets, where the order of calculations can be determined based on dependencies
between the formulas in the cells.
If you have written formulas in a spreadsheet such as Excel, you may recognize the formulas on the left will
result in the values on the right when calculated:

In M, an expression can reference previous expressions by name, and the evaluation process will automatically
determine the order in which referenced expressions are calculated.
Let's use a record to produce an expression which is equivalent to the above spreadsheet example. When
initializing the value of a field, you refer to other fields within the record by the name of the field, as follows:

[
A1 = A2 * 2,
A2 = A3 + 1,
A3 = 1
]

The above expression evaluates to the following record:

[
A1 = 4,
A2 = 2,
A3 = 1
]

Records can be contained within, or nested , within other records. You can use the lookup operator ([ ]) to
access the fields of a record by name. For example, the following record has a field named Sales containing a
record, and a field named Total that accesses the FirstHalf and SecondHalf fields of the Sales record:

[
Sales = [ FirstHalf = 1000, SecondHalf = 1100 ],
Total = Sales[FirstHalf] + Sales[SecondHalf]
]

The above expression evaluates to the following record:


[
Sales = [ FirstHalf = 1000, SecondHalf = 1100 ],
Total = 2100
]

You use the positional index operator ({ }) to access an item in a list by its numeric index. The values within a
list are referred to using a zero-based index from the beginning of the list. For example, the indexes 0 and 1 are
used to reference the first and second items in the list below:

[
Sales =
{
[
Year = 2007,
FirstHalf = 1000,
SecondHalf = 1100,
Total = FirstHalf + SecondHalf // equals 2100
],
[
Year = 2008,
FirstHalf = 1200,
SecondHalf = 1300,
Total = FirstHalf + SecondHalf // equals 2500
]
},
#"Total Sales" = Sales{0}[Total] + Sales{1}[Total] // equals 4600
]

Lazy and eager evaluation


List , Record , and Table member expressions, as well as let expressions (Go to Expressions, values, and let
expression), are evaluated using lazy evaluation . That is, they are evaluated when needed. All other
expressions are evaluated using eager evaluation . That is, they are evaluated immediately when encountered
during the evaluation process. A good way to think about this is to remember that evaluating a list or record
expression will return a list or record value that knows how its list items or record fields need to computed,
when requested (by lookup or index operators).
Operators
9/13/2022 • 2 minutes to read

The Power Query M formula language includes a set of operators that can be used in an expression. Operators
are applied to operands to form symbolic expressions. For example, in the expression 1 + 2 the numbers 1 and
2 are operands and the operator is the addition operator (+).
The meaning of an operator can vary depending on the type of operand values. The language has the following
operators:
Plus operator (+)
EXP RESSIO N EQ UA L S

1+2 Numeric addition: 3

#time(12,23,0) + #duration(0,0,2,0) Time arithmetic: #time(12,25,0)

Combination operator (&)


F UN C T IO N EQ UA L S

"A" & "BC" Text concatenation: "ABC"

{1} & {2, 3} List concatenation: {1, 2, 3}

[a=1]&[b=2] Record merge: [ a = 1, b = 2 ]

List of M operators
Common operators which apply to null, logical, number, time, date, datetime, datetimezone, duration, text,
binary)

O P ERATO R DESC RIP T IO N

> Greater than

>= Greater than or equal

< Less than

<= Less than or equal

= Equal

<> Not equal

Logical operators (In addition to Common operators )


O P ERATO R DESC RIP T IO N

or Conditional logical OR

and Conditional logical AND

not Logical NOT

Number operators (In addition to Common operators )

O P ERATO R DESC RIP T IO N

+ Sum

- Difference

* Product

/ Quotient

+x Unary plus

-x Negation

Text operators (In addition to Common operators )

O P ERATO R DESC RIP T IO N

& Concatenation

List, record, table operators

O P ERATO R DESC RIP T IO N

= Equal

<> Not equal

& Concatenation

Record lookup operator

O P ERATO R DESC RIP T IO N

[] Access the fields of a record by name.

List indexer operator

O P ERATO R DESC RIP T IO N

{} Access an item in a list by its zero-based numeric index.

Type compatibility and asser tion operators


O P ERATO R DESC RIP T IO N

is The expression x is y returns true if the type of x is


compatible with y, and returns false if the type of x is not
compatible with y.

as The expression x as y asserts that the value x is compatible


with y as per the is operator.

Date operators

O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x+y time duration Date offset by duration

x+y duration time Date offset by duration

x-y time duration Date offset by negated


duration

x-y time time Duration between dates

x&y date time Merged datetime

Datetime operators

O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x+y datetime duration Datetime offset by duration

x+y duration datetime Datetime offset by duration

x-y datetime duration Datetime offset by negated


duration

x-y datetime datetime Duration between


datetimes

Datetimezone operators

O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x+y datetimezone duration Datetimezone offset by


duration

x+y duration datetimezone Datetimezone offset by


duration

x-y datetimezone duration Datetimezone offset by


negated duration

x-y datetimezone datetimezone Duration between


datetimezones

Duration operators
O P ERATO R L EF T O P ERA N D RIGH T O P ERA N D M EA N IN G

x+y datetime duration Datetime offset by duration

x+y duration datetime Datetime offset by duration

x+y duration duration Sum of durations

x-y datetime duration Datetime offset by negated


duration

x-y datetime datetime Duration between


datetimes

x-y duration duration Difference of durations

x*y duration number N times a duration

x*y number duration N times a duration

x/y duration number Fraction of a duration

NOTE
Not all combinations of values may be supported by an operator. Expressions that, when evaluated, encounter undefined
operator conditions evaluate to errors. For more information about errors in M, go to Errors

Error example :

F UN C T IO N EQ UA L S

1 + "2" Error: adding number and text is not supported


Type conversion
9/13/2022 • 2 minutes to read

The Power Query M formula language has formulas to convert between types. The following is a summary of
conversion formulas in M.

Number
T Y P E C O N VERSIO N DESC RIP T IO N

[Link](text as text) as number Returns a number value from a text value.

[Link](number as number) as text Returns a text value from a number value.

[Link](value as any) as number Returns a number value from a value.

[Link](value as any) as number Returns a 32-bit integer number value from the given value.

[Link](value as any) as number Returns a 64-bit integer number value from the given value.

[Link](value as any) as number Returns a Single number value from the given value.

[Link](value as any) as number Returns a Double number value from the given value.

[Link](value as any) as number Returns a Decimal number value from the given value.

[Link](value as any) as number Returns a Currency number value from the given value.

Text
T Y P E C O N VERSIO N DESC RIP T IO N

[Link](value as any) as text Returns the text representation of a number, date, time,
datetime, datetimezone, logical, duration or binary value.

Logical
T Y P E C O N VERSIO N DESC RIP T IO N

[Link](text as text) as logical Returns a logical value of true or false from a text value.

[Link](logical as logical) as text Returns a text value from a logical value.

[Link](value as any) as logical Returns a logical value from a value.

Date, Time, DateTime, and DateTimeZone


T Y P E C O N VERSIO N DESC RIP T IO N

.FromText(text as text) as date, time, datetime, or Returns a date, time, datetime, or datetimezone value from a
datetimezone set of date formats and culture value.

.ToText(date, time, dateTime, or dateTimeZone as Returns a text value from a date, time, datetime, or
date, time, datetime, or datetimezone) as text datetimezone value.

.From(value as any) Returns a date, time, datetime, or datetimezone value from a


value.

.ToRecord(date, time, dateTime, or dateTimeZone as date, Returns a record containing parts of a date, time, datetime,
time, datetime, or datetimezone) or datetimezone value.
Metadata

9/13/2022 • 2 minutes to read

Metadata is information about a value that is associated with a value. Metadata is represented as a record
value, called a metadata record. The fields of a metadata record can be used to store the metadata for a value.
Every value has a metadata record. If the value of the metadata record has not been specified, then the metadata
record is empty (has no fields). Associating a metadata record with a value does not change the value’s behavior
in evaluations except for those that explicitly inspect metadata records.
A metadata record value is associated with a value x using the syntax value meta [record]. For example, the
following associates a metadata record with Rating and Tags fields with the text value "Mozart":

"Mozart" meta [ Rating = 5,


Tags = {"Classical"} ]

A metadata record can be accessed for a value using the [Link] function. In the following example, the
expression in the ComposerRating field accesses the metadata record of the value in the Composer field, and
then accesses the Rating field of the metadata record.

[
Composer = "Mozart" meta [ Rating = 5, Tags = {"Classical"} ],
ComposerRating = [Link](Composer)[Rating] // 5
]

Metadata records are not preserved when a value is used with an operator or function that constructs a new
value. For example, if two text values are concatenated using the & operator, the metadata of the resulting text
value is an empty record [].
The standard library functions [Link] and [Link] can be used to remove all
metadata from a value and to replace a value’s metadata.
Errors
9/13/2022 • 2 minutes to read

An error in Power Query M formula language is an indication that the process of evaluating an expression
could not produce a value. Errors are raised by operators and functions encountering error conditions or by
using the error expression. Errors are handled using the tr y expression. When an error is raised, a value is
specified that can be used to indicate why the error occurred.

Try expression
A try expression converts values and errors into a record value that indicates whether the try expression
handled an error, or not, and either the proper value or the error record it extracted when handling the error. For
example, consider the following expression that raises an error and then handles it right away:

try error "negative unit count"

This expression evaluates to the following nested record value, explaining the [HasError], [Error] , and
[Message] field lookups in the unit-price example before.

Error record
[
HasError = true,
Error =
[
Reason = "[Link]",
Message = "negative unit count",
Detail = null
]
]

A common case is to replace errors with default values. The try expression can be used with an optional
otherwise clause to achieve just that in a compact form:

try error "negative unit count" otherwise 42


// equals 42

Error example
let Sales =
[
ProductName = "Fishing rod",
Revenue = 2000,
Units = 1000,
UnitPrice = if Units = 0 then error "No Units"
else Revenue / Units
],

//Get UnitPrice from Sales record


textUnitPrice = try [Link](Sales[UnitPrice]),
Label = "Unit Price: " &
(if textUnitPrice[HasError] then textUnitPrice[Error][Message]
//Continue expression flow
else textUnitPrice[Value])
in
Label

The previous example accesses the Sales[UnitPrice] field and formats the value producing the result:

"Unit Price: 2"

If the Units field had been zero, then the UnitPrice field would have raised an error which would have been
handled by the try. The resulting value would then have been:

"No Units"
Power Query M function reference
9/13/2022 • 2 minutes to read

The Power Query M function reference includes articles for each of the over 700 functions. These reference
articles are auto-generated from in-product help. To learn more about functions and how they work in an
expression, see Understanding Power Query M functions.

Functions by category
Accessing data functions
Binary functions
Combiner functions
Comparer functions
Date functions
DateTime functions
DateTimeZone functions
Duration functions
Error handling
Expression functions
Function values
List functions
Lines functions
Logical functions
Number functions
Record functions
Replacer functions
Splitter functions
Table functions
Text functions
Time functions
Type functions
Uri functions
Value functions
Understanding Power Query M functions
9/13/2022 • 2 minutes to read

In the Power Query M formula language, a function is a mapping from a set of input values to a single output
value. A function is written by first naming the function parameters, and then providing an expression to
compute the result of the function. The body of the function follows the goes-to (=>) symbol. Optionally, type
information can be included on parameters and the function return value. A function is defined and invoked in
the body of a let statement. Parameters and/or return value can be implicit or explicit. Implicit parameters
and/or return value are of type any . Type any is similar to an object type in other languages. All types in M
derive from type any .
A function is a value just like a number or a text value, and can be included in-line just like any other
expression. The following example shows a function which is the value of an Add variable which is then invoked,
or executed, from several other variables. When a function is invoked, a set of values are specified which are
logically substituted for the required set of input values within the function body expression.
Example – Explicit parameters and return value

let
AddOne = (x as number) as number => x + 1,
//additional expression steps
CalcAddOne = AddOne(5)
in
CalcAddOne

Example – Implicit parameters and return value

let
Add = (x, y) => x + y,
AddResults =
[
OnePlusOne = Add(1, 1), // equals 2
OnePlusTwo = Add(1, 2) // equals 3
]
in
AddResults

Find the first element of a list greater than 5, or null other wise

let
FirstGreaterThan5 = (list) =>
let
GreaterThan5 = [Link](list, (n) => n> 5),
First = [Link](GreaterThan5)
in
First,
Results =
[
Found = FirstGreaterThan5({3,7,9}), // equals 7
NotFound = FirstGreaterThan5({1,3,4}) // equals null
]
in
Results
Functions can be used recursively. In order to recursively reference the function, prefix the identifier with @.

let
fact = (num) => if num = 0 then 1 else num * @fact (num-1)
in
fact(5) // equals 120

Each keyword
The each keyword is used to easily create simple functions. "each ..." is syntactic sugar for a function signature
that takes the _ parameter "(_) => ..."
Each is useful when combined with the lookup operator, which is applied by default to _
For example, each [CustomerID] is the same as each _[CustomerID], which is the same as (_) => _[CustomerID]
Example – Using each in table row filter

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"] ,
[CustomerID = 3, Name = "Paul", Phone = "543-7890"] ,
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
each [CustomerID] = 2
)[Name]

// equals "Jim"
Accessing data functions
9/13/2022 • 7 minutes to read

These functions access data and return table values. Most of these functions return a table value called a
navigation table . Navigation tables are primarily used by the Power Query user interface to provide a
navigation experience over the potentially large hierarchical data sets returned.

NAME DESC RIP T IO N

[Link] Returns a list of identities that the condition will accept.

[Link] Returns a structural representation of an Microsoft Access


database.

[Link] Returns a list of Active Directory domains in the same forest


as the specified domain or of the current machine's domain if
none is specified.

[Link] Returns the report suites in Adobe Analytics.

[Link] Returns the schema collection for an [Link] data source.

[Link] Returns the schema collection for an [Link] data source.

[Link] Returns a table of multidimensional cubes or tabular models


from the Analysis Services database.

[Link] Returns the Analysis Services databases on a particular host.

[Link] Returns the content of the specified blob from an Azure


storage vault.

[Link] Returns a navigational table containing all containers found


in the Azure Storage account. Each row has the container
name and a link to the container blobs.

[Link] Returns a navigational table containing the documents


found in the specified container and its subfolders from
Azure Data Lake Storage.

[Link] Returns the content of the specified file from an Azure Data
Lake Storage filesystem.

[Link] Returns a navigational table containing a row for each table


found at the account URL from an Azure storage vault. Each
row contains a link to the azure table.

[Link] This function is unavailable because it requires .NET 4.5.

[Link] Returns the contents of a CSV document as a table using the


specified encoding.
NAME DESC RIP T IO N

[Link] Merges the specified dimension table, dimensionSelector,


into the cube's, cube, filter context and changes the
dimensional granularity by expanding the specified set,
attributeNames, of dimension attributes.

[Link] Adds a column with the name column to the cube that
contains the results of the measure measureSelector applied
in the row context of each row.

[Link] Returns a cube after applying parameter with arguments to


cube.

[Link] Returns the unique member identifier from a member


property value.

[Link] Returns the property propertyName of dimension attribute


attribute .

[Link] Changes the dimensional granularity of the filter context for


the cube by collapsing the attributes mapped to the
specified columns columnNames.

[Link] Returns a table containing the set of available dimensions


within the cube.

[Link] Returns a nested tree of tables representing the display


folder hierarchy of the objects (for example, dimensions and
measures).

[Link] Returns a table containing the set of available properties for


measures that are expanded in the cube.

[Link] Returns the property of a measure.

[Link] Returns a table containing the set of available measures


within the cube.

[Link] Returns a table containing the set of parameters that can be


applied to cube.

[Link] Returns a table containing the set of available properties for


dimensions that are expanded in the cube.

[Link] Returns the key of property property .

[Link] Replaces the set of dimensions returned by


[Link].

[Link] Applies the list cube functions, transforms, on the cube.

[Link] Returns a table of SQL tables and views available in a Db2


database.
NAME DESC RIP T IO N

[Link] Returns the cubes in an Essbase instance grouped by


Essbase server.

[Link] Returns the tables in the current Excel Workbook.

[Link] Returns a table representing sheets in the given excel


workbook.

[Link] Returns a table of contents from a Microsoft Exchange


account.

[Link] Returns the binary contents of the file located at a path.

[Link] Returns a table containing the properties and contents of


the files and folders found in the specified folder.

[Link] Returns a table containing a row for each file found at a


folder path, and subfolders. Each row contains properties of
the folder or file and a link to its content.

[Link] Returns the Google Analytics accounts for the current


credential.

[Link] Returns a table containing a row for each folder and file
found at the folder url, {0}, from a Hadoop file system. Each
row contains properties of the folder or file and a link to its
content.

[Link] Returns a table containing a row for each file found at the
folder url, {0}, and subfolders from a Hadoop file system.
Each row contains properties of the file and a link to its
content.

[Link] Returns a navigational table containing all containers found


in the HDInsight account. Each row has the container name
and table containing its files.

[Link] Returns a navigational table containing all containers found


in the HDInsight account. Each row has the container name
and table containing its files.

[Link] Returns a table containing a row for each folder and file
found at the container URL, and subfolders from an
HDInsight account. Each row contains properties of the
file/folder and a link to its content.

[Link] Returns a table containing the results of running the


specified CSS selectors against the provided html.

[Link] Creates an identity.

[Link] Determines whether an identity is a member of an identity


collection.
NAME DESC RIP T IO N

[Link] The default identity provider for the current host.

[Link] Returns a table of SQL tables and views available in an


Informix database on server server in the database
instance named database .

[Link] Returns the contents of a JSON document. The contents


may be directly passed to the function as text, or it may be
the binary value returned by a function like [Link].

[Link] Produces a JSON representation of a given value value with


a text encoding specified by encoding.

[Link] Returns a table with data relating to the tables in the


specified MySQL Database.

[Link] Returns a table of OData feeds offered by an OData


serviceUri.

[Link] Returns a table of SQL tables and views from the ODBC data
source specified by the connection string
connectionString .

[Link] Returns the result of trying to infer SQL capabilities for an


ODBC driver.

[Link] Connects to a generic provider with the given connection


string and returns the result of evaluating the query.

[Link] Returns a table of SQL tables and views from the OLE DB
data source specified by the connection string.

[Link] Returns the result of running a native query on an OLE DB


data source.

[Link] Returns a table with data relating to the tables in the


specified Oracle Database.

[Link] Returns any tables found in pdf.

[Link] Returns a table with data relating to the tables in the


specified PostgreSQL Database.

[Link] Returns a record of data frames from the RData file.

[Link] Connects to the Salesforce Objects API and returns the set
of available objects (i.e. Accounts).

[Link] Connects to the Salesforce Reports API and returns the set
of available reports.

[Link] Returns the InfoCubes and queries in an SAP Business


Warehouse system grouped by InfoArea.
NAME DESC RIP T IO N

[Link] Returns the packages in an SAP HANA database.

[Link] Returns a table containing a row for each folder and


document found at the SharePoint site url. Each row
contains properties of the folder or file and a link to its
content.

[Link] Returns a table containing a row for each document found at


the SharePoint site url, and subfolders. Each row contains
properties of the folder or file and a link to its content.

[Link] Returns a table containing the result of a SharePoint List as


an OData feed.

[Link] Returns the resulting table of a CSV file that can be accessed
using the SODA 2.0 API. The URL must point to a valid
SODA-compliant source that ends in a .csv extension.

[Link] Returns a table containing SQL tables located on a SQL


Server instance database.

[Link] Returns a table with references to databases located on a


SQL Server instance. Returns a navigation table.

[Link] Returns a table with data relating to the tables in the


specified Sybase Database.

[Link] Returns a table with data relating to the tables in the


specified Teradata Database.

[Link] Creates an action that, when executed, will return the results
of performing a method request against url using HTTP as a
binary value.

[Link] Returns the HTML for the specified url, as viewed by a web
browser.

[Link] Returns the contents downloaded from a web url as a binary


value.

[Link] Returns the HTTP headers downloaded from the url as a


record value.

[Link] Returns the contents of an HTML webpage as a table.

[Link] Returns the contents of an XML document as a hierarchical


table (list of records).

[Link] Returns the contents of an XML document as a nested


collection of flattened tables.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](identityProvider as function, condition as function) as
list

About
Using the specified identityProvider , converts the condition into the list of identities for which condition
would return true in all authorization contexts with identityProvider as the identity provider. An error is
raised if it is not possible to convert condition into a list of identities, for example if condition consults
attributes other than user or group identities to make a decision.
Note that the list of identities represents the identities as they appear in condition and no normalization (such
as group expansion) is performed on them.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](database as binary, optional options as nullable record) as table

About
Returns a structural representation of an Access database, database . An optional record parameter, options ,
may be specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is false).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.

The record parameter is specified as [option1 = value1, option2 = value2...], for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](optional forestRootDomainName as nullable text) as table

About
Returns a list of Active Directory domains in the same forest as the specified domain or of the current machine's
domain if none is specified.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](optional options as nullable record) as table

About
Returns a table of multidimensional packages from Adobe Analytics. An optional record parameter, options ,
may be specified to control the following options:
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
MaxRetryCount : The number of retries to perform when polling for the result of the query. The default value
is 120.
RetryInterval : The duration of time between retry attempts. The default value is 1 second.
Implementation : Specifies Adobe Analytics API version. Valid values are: "2.0". Default uses API version 1.4.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](providerName as text, connectionString as any, optional options as nullable
record) as table

About
Returns the schema collection for the [Link] data source with provider name providerName and connection
string connectionString . connectionString can be text or a record of property value pairs. Property values can
either be text or number. An optional record parameter, options , may be provided to specify additional
properties. The record can contain the following fields:
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
SqlCompatibleWindowsAuth : A logical (true/false) that determines whether to produce SQL Server-compatible
connection string options for Windows authentication. The default value is true.
TypeMap
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](providerName as text, connectionString as any, query as text, optional options
as nullable record) as table

About
Returns the result of running query with the connection string connectionString using the [Link] provider
providerName . connectionString can be text or a record of property value pairs. Property values can either be
text or number. An optional record parameter, options , may be provided to specify additional properties. The
record can contain the following fields:
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
SqlCompatibleWindowsAuth : A logical (true/false) that determines whether to produce SQL Server-compatible
connection string options for Windows authentication. The default value is true.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record)
as table

About
Returns a table of multidimensional cubes or tabular models from the Analysis Services database database on
server server . An optional record parameter, options , may be specified to control the following options:
Query : A native MDX query used to retrieve data.
TypedMeasureColumns : A logical value indicating if the types specified in the multidimensional or tabular
model will be used for the types of the added measure columns. When set to false, the type "number" will be
used for all measure columns. The default value for this option is false.
Culture : A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier'
connection string property.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is driver-dependent.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
SubQueries : A number (0, 1 or 2) that sets the value of the "SubQueries" property in the connection string.
This controls the behavior of calculated members on subselects or subcubes. (The default value is 2).
Implementation
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, optional options as nullable record) as table

About
Returns databases on an Analysis Services instance, server . An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
TypedMeasureColumns : A logical value indicating if the types specified in the multidimensional or tabular
model will be used for the types of the added measure columns. When set to false, the type "number" will be
used for all measure columns. The default value for this option is false.
Culture : A culture name specifying the culture for the data. This corresponds to the 'Locale Identifier'
connection string property.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is driver-dependent.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
SubQueries : A number (0, 1 or 2) that sets the value of the "SubQueries" property in the connection string.
This controls the behavior of calculated members on subselects or subcubes. (The default value is 2).
Implementation
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as binary

About
Returns the content of the blob at the URL, url , from an Azure storage vault. options may be specified to
control the following options:
BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4
MB.
ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the
number of requests to be made in parallel, at the cost of memory utilization. The memory required is
(ConcurrentRequest * RequestSize). The default value is 16.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](account as text, optional options as nullable record) as table

About
Returns a navigational table containing a row for each container found at the account URL, account , from an
Azure storage vault. Each row contains a link to the container blobs. options may be specified to control the
following options:
BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4
MB.
ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the
number of requests to be made in parallel, at the cost of memory utilization. The memory required is
(ConcurrentRequest * RequestSize). The default value is 16.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](endpoint as text, optional options as nullable record) as table

About
Returns a navigational table containing the documents found in the specified container and its subfolders at the
account URL, endpoint , from an Azure Data Lake Storage filesystem. options may be specified to control the
following options:
BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4
MB.
ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the
number of requests to be made in parallel, at the cost of memory utilization. The memory required is
(ConcurrentRequest * RequestSize). The default value is 16.
HierarchicalNavigation : A logical (true/false) that controls whether the files are returned in a tree-like
directory view or in a flat list. The default value is false.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as binary

About
Returns the content of the file at the URL, url , from an Azure Data Lake Storage filesystem. options may be
specified to control the following options:
BlockSize : The number of bytes to read before waiting on the data consumer. The default value is 4 MB.
RequestSize : The number of bytes to try to read in a single HTTP request to the server. The default value is 4
MB.
ConcurrentRequests : The ConcurrentRequests option supports faster download of data by specifying the
number of requests to be made in parallel, at the cost of memory utilization. The memory required is
(ConcurrentRequest * RequestSize). The default value is 16.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](account as text, optional options as nullable record) as table

About
Returns a navigational table containing a row for each table found at the account URL, account , from an Azure
storage vault. Each row contains a link to the azure table. An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
Timeout : A duration that controls how long to wait before abandoning the request to the server. The default
value is source-specific.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as table

About
This function is unavailable because it requires .NET 4.5.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](source as any, optional columns as any, optional delimiter as any, optional
extraValues as nullable number, optional encoding as nullable number) as table

About
Returns the contents of the CSV document as a table.
columns can be null, the number of columns, a list of column names, a table type, or an options record.
delimiter can be a single character, or a list of characters. Default: "," .
Refer to [Link] for the supported values of extraValues .
encoding specifies the text encoding type.

If a record is specified for columns (and delimiter , extraValues , and encoding are null), the following record
fields may be provided:
Delimiter : The column delimiter. Default: "," .
Columns : Can be null, the number of columns, a list of column names, or a table type. If the number of
columns is lower than the number found in the input, the additional columns will be ignored. If the number
of columns is higher than the number found in the input, the additional columns will be null. When not
specified, the number of columns will be determined by what is found in the input.
Encoding : The text encoding of the file. Default: 65001 (UTF-8).
CsvStyle : Specifies how quotes are handled. [Link] (default): Quotes in a field are
only significant immediately following the delimiter. [Link]: Quotes in a field are always
significant, regardless of where they appear.
QuoteStyle : Specifies how quoted line breaks are handled. [Link] (default): All line breaks are
treated as the end of the current row, even when they occur inside a quoted value. [Link]: Quoted
line breaks are treated as part of the data, not as the end of the current row.

Example 1
Process CSV text with column headers.
Usage

let
csv = [Link]({"OrderID,Item", "1,Fishing rod", "2,1 lb. worms"}, "#(cr)#(lf)")
in
[Link]([Link](csv))

Output
[Link]({
[OrderID = "1", Item = "Fishing rod"],
[OrderID = "2", Item = "1 lb. worms"]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**cube** as table, **dimensionSelector** as any,
**attributeNames** as list, optional **newColumnNames** as any) as table

About
Merges the specified dimension table, dimensionSelector , into the cube's, cube , filter context and changes the
dimensional granularity by expanding the specified set, attributeNames , of dimension attributes. The dimension
attributes are added to the tabular view with columns named newColumnNames , or attributeNames if not
specified.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**cube** as table, **column** as text, **measureSelector** as any) as
table

About
Adds a column with the name column to the cube that contains the results of the measure measureSelector
applied in the row context of each row. Measure application is affected by changes to dimension granularity and
slicing. Measure values will be adjusted after certain cube operations are performed.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](cube as table, parameter as any, optional arguments as nullable list) as
table

About
Returns a cube after applying parameter with arguments to cube .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](attribute as any) as any

About
Returns the unique member identifier from a member property value. attribute . Returns null for any other
values.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](attribute as any, propertyName as text) as any

About
Returns the property propertyName of dimension attribute attribute .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**cube** as table, **columnNames** as list) as table

About
Changes the dimensional granularity of the filter context for the cube by collapsing the attributes mapped to
the specified columns columnNames . The columns are also removed from the tabular view of the cube.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**cube** as table) as table

About
Returns a table containing the set of available dimensions within the cube . Each dimension is a table containing
a set of dimension attributes and each dimension attribute is represented as a column in the dimension table.
Dimensions can be expanded in the cube using [Link].
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**cube** as table) as table

About
Returns a nested tree of tables representing the display folder hierarchy of the objects (for example, dimensions
and measures) available for use in the cube .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](cube as table) as table

About
Returns a table containing the set of available properties for measures that are expanded in the cube.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](measure as any, propertyName as text) as any

About
Returns the property propertyName of measure measure .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**cube** as any) as table

About
Returns a table containing the set of available measures within the cube . Each measure is represented as a
function. Measures can be applied to the cube using [Link].
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](cube as table) as table

About
Returns a table containing the set of parameters that can be applied to cube . Each parameter is a function that
can be invoked to get cube with the parameter and its arguments applied.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](cube as table) as table

About
Returns a table containing the set of available properties for dimensions that are expanded in the cube.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](property as any) as any

About
Returns the key of property property .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](cube as table, dimensions as table) as table

About
Replaces the set of dimensions returned by [Link] . For example, this function can be used to add an
ID column to a dimension attribute, so that the data source can group on the ID rather than the displayed value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](cube as table, transforms as list) as table

About
Applies the list cube functions, transforms , on the cube .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record) as table

About
Returns a table of SQL tables and views available in a Db2 database on server server in the database instance
named database . The port may be optionally specified with the server, separated by a colon. An optional record
parameter, options , may be specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
Implementation : Specifies the internal database provider implementation to use. Valid values are: "IBM" and
"Microsoft".
BinaryCodePage : A number for the CCSID (Coded Character Set Identifier) to decode Db2 FOR BIT binary
data into character strings. Applies to Implementation = "Microsoft". Set 0 to disable conversion (default). Set
1 to convert based on database encoding. Set other CCSID number to convert to application encoding.
PackageCollection : Specifies a string value for package collection (default is "NULLID") to enable use of
shared packages required to process SQL statements. Applies to Implementation = "Microsoft".
UseDb2ConnectGateway : Specifies whether the connection is being made through a Db2 Connect gateway.
Applies to Implementation = "Microsoft".
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as table

About
Returns a table of cubes grouped by Essbase server from an Essbase instance at APS server url . An optional
record parameter, options , may be specified to control the following options:
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as table

About
Returns the contents of the current Excel workbook.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](workbook as binary, optional useHeaders as any, optional delayTypes as nullable
logical) as table

About
Returns the contents of the Excel workbook.
useHeaders can be null, a logical (true/false) value indicating whether the first row of each returned table
should be treated as a header, or an options record. Default: false.
delayTypes can be null or a logical (true/false) value indicating whether the columns of each returned table
should be left untyped. Default: false.
If a record is specified for useHeaders (and delayTypes is null), the following record fields may be provided:
UseHeaders : Can be null or a logical (true/false) value indicating whether the first row of each returned table
should be treated as a header. Default: false.
DelayTypes : Can be null or a logical (true/false) value indicating whether the columns of each returned table
should be left untyped. Default: false.
InferSheetDimensions : Can be null or a logical (true/false) value indicating whether the area of a worksheet
that contains data should be inferred by reading the worksheet itself, rather than by reading the dimensions
metadata from the file. This can be useful in cases where the dimensions metadata is incorrect. Note that this
option is only supported for Open XML Excel files, not for legacy Excel files. Default: false.

Example 1
Return the contents of Sheet1 from an Excel workbook.
Usage

[Link]([Link]("C:\[Link]"), null, true){[Item="Sheet1"]}[Data]

Output

[Link]({
[Column1 = "ID", Column2 = "Name", Column3 = "Phone"],
[Column1 = 1, Column2 = "Bob", Column3 = "123-4567"],
[Column1 = 3, Column2 = "Pam", Column3 = "543-7890"],
[Column1 = 2, Column2 = "Jim", Column3 = "987-6543"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link] (optional mailboxAddress as nullable text) as table

About
Returns a table of contents from the Microsoft Exchange account mailboxAddress . If mailboxAddress is not
specified, the default account for the credential will be used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](path as text, optional options as nullable record) as binary

About
Returns the contents of the file, path , as binary. The options parameter is currently intended for internal use
only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](path as text, optional options as nullable record) as table

About
Returns a table containing a row for each folder and file found in the folder path . Each row contains properties
of the folder or file and a link to its content. The options parameter is currently intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](path as text, optional options as nullable record) as table

About
Returns a table containing a row for each file found in the folder path and all its subfolders. Each row contains
properties of the file and a link to its content. The options parameter is currently intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as table

About
Returns Google Analytics accounts that are accessible from the current credential.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text) as table

About
Returns a table containing a row for each folder and file found at the folder URL, url , from a Hadoop file
system. Each row contains properties of the folder or file and a link to its content.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text) as table

About
Returns a table containing a row for each file found at the folder URL, url , and subfolders from a Hadoop file
system. Each row contains properties of the file and a link to its content.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](account as text) as table

About
Returns a navigational table containing a row for each container found at the account URL, account , from an
Azure storage vault. Each row contains a link to the container blobs.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](account as text) as table

About
Returns a navigational table containing a row for each container found at the account URL, account , from an
Azure storage vault. Each row contains a link to the container blobs.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](account as text, containerName as text) as table

About
Returns a table containing a row for each blob file found at the container URL, account , from an Azure storage
vault. Each row contains properties of the file and a link to its content.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](html as any, columnNameSelectorPairs as list, optional options as nullable record) as
table

About
Returns a table containing the results of running the specified CSS selectors against the provided html . An
optional record parameter, options , may be provided to specify additional properties. The record can contain
the following fields:
RowSelector

Example 1
Returns a table from a sample html text value.
Usage

[Link]("<div class=""name"">Jo</div><span>Manager</span>", {{"Name", ".name"}, {"Title", "span"}},


[RowSelector=".name"])\

Output
#table({"Name", "Title"}, {{"Jo", "Manager"}})

Example 2
Extracts all the hrefs from a sample html text value.
Usage

[Link]("<a href=""/[Link]"">Test</a>", {{"Link", "a", each [Attributes][href]}})

Output
#table({"Link"}, {{"/[Link]"}})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](identityProvider as function, value as any) as record

About
Creates an identity.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](identity as record, collection as record) as logical

About
Determines whether an identity is a member of an identity collection.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as any

About
The default identity provider for the current host.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record) as
table

About
Returns a table of SQL tables and views available in an Informix database on server server in the database
instance named database . The port may be optionally specified with the server, separated by a colon. An
optional record parameter, options , may be specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](jsonText as any, optional encoding as nullable number) as any

About
Returns the content of the JSON document.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional encoding as nullable number) as binary

About
Produces a JSON representation of a given value value with a text encoding specified by encoding . If
encoding is omitted, UTF8 is used. Values are represented as follows:

Null, text and logical values are represented as the corresponding JSON types
Numbers are represented as numbers in JSON, except that #infinity , -#infinity and #nan are converted
to null
Lists are represented as JSON arrays
Records are represnted as JSON objects
Tables are represented as an array of objects
Dates, times, datetimes, datetimezones and durations are represented as ISO-8601 text
Binary values are represented as base-64 encoded text
Types and functions produce an error

Example 1
Convert a complex value to JSON.
Usage

[Link]([Link]([A = {1, true, "3"}, B = #date(2012, 3, 25)]))

Output
"{""A"":[1,true,""3""],""B"":""2012-03-25""}"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record) as table

About
Returns a table of SQL tables, views, and stored scalar functions available in a MySQL database on server
server in the database instance named database . The port may be optionally specified with the server,
separated by a colon. An optional record parameter, options , may be specified to control the following options:
Encoding : A TextEncoding value that specifies the character set used to encode all queries sent to the server
(default is null).
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
TreatTinyAsBoolean : A logical (true/false) that determines whether to force tinyint columns on the server as
logical values. The default value is true.
OldGuids : A logical (true/false) that sets whether char(36) columns (if false) or binary(16) columns (if true)
will be treated as GUIDs. The default value is false.
ReturnSingleDatabase : A logical (true/false) that sets whether to return all tables of all databases (if false) or
to return tables and views of the specified database (if true). The default value is false.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](serviceUri as text, optional headers as nullable record, optional options as any) as
any

About
Returns a table of OData feeds offered by an OData service from a uri serviceUri , headers headers . A boolean
value specifying whether to use concurrent connections or an optional record parameter, options , may be
specified to control the following options:
Query : Programmatically add query parameters to the URL without having to worry about escaping.
Headers : Specifying this value as a record will supply additional headers to an HTTP request.
ExcludedFromCacheKey : Specifying this value as a list will exclude these HTTP header keys from being part of
the calculation for caching data.
ApiKeyName : If the target site has a notion of an API key, this parameter can be used to specify the name (not
the value) of the key parameter that must be used in the URL. The actual key value is provided in the
credential.
Timeout : Specifying this value as a duration will change the timeout for an HTTP request. The default value is
600 seconds.
EnableBatch : A logical (true/false) that sets whether to allow generation of an OData $batch request if the
MaxUriLength is exceeded (default is false).
`MaxUriLength: A number that indicates the max length of an allowed uri sent to an OData service. If
exceeded and EnableBatch is true then the request will be made to an OData $batch endpoint, otherwise it
will fail (default is 2048).
Concurrent : A logical (true/false) when set to true, requests to the service will be made concurrently. When
set to false, requests will be made sequentially. When not specified, the value will be determined by the
service’s AsynchronousRequestsSupported annotation. If the service does not specify whether
AsynchronousRequestsSupported is supported, requests will be made sequentially.
ODataVersion : A number (3 or 4) that specifies the OData protocol version to use for this OData service.
When not specified, all supported versions will be requested. The service version will be determined by the
OData-Version header returned by the service.
FunctionOverloads : A logical (true/false) when set to true, function import overloads will be listed in the
navigator as separate entries, when set to false, function import overloads will be listed as one union
function in the navigator. Default value for V3: false. Default value for V4: true.
MoreColumns : A logical (true/false) when set to true, adds a "More Columns" column to each entity feed
containing open types and polymorphic types. This will contain the fields not declared in the base type. When
false, this field is not present. Defaults to false.
IncludeAnnotations : A comma separated list of namespace qualified term names or patterns to include with
"*" as a wildcard. By default, none of the annotations are included.
IncludeMetadataAnnotations : A comma separated list of namespace qualified term names or patterns to
include on metadata document requests, with "*" as a wildcard. By default, includes the same annotations as
IncludeAnnotations.
OmitValues : Allows the OData service to avoid writing out certain values in responses. If acknowledged by
the service, we will infer those values from the omitted fields. Options include:
[Link] : Allows the OData service to omit null values.
Implementation : Specifies the implementation of the OData connector to use. Valid values are "2.0" or null.

Example 1
Connect to the TripPin OData service.
Usage

[Link]("[Link]

Output
table
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](connectionString as any, optional options as nullable record) as table

About
Returns a table of SQL tables and views from the ODBC data source specified by the connection string
connectionString . connectionString can be text or a record of property value pairs. Property values can either
be text or number. An optional record parameter, options , may be provided to specify additional properties. The
record can contain the following fields:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is 15 seconds.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
SqlCompatibleWindowsAuth : A logical (true/false) that determines whether to produce SQL Server-compatible
connection string options for Windows authentication. The default value is true.

Example 1
Return the SQL tables and views from the provided connection string.
Usage

[Link]("dsn=your_dsn")

Output

table
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](connectionString as any) as record

About
Returns the result of trying to infer SQL capbabilities with the connection string connectionString using ODBC.
connectionString can be text or a record of property value pairs. Property values can either be text or number.

Example 1
Return the inferred SQL capabilities for a connection string.
Usage

[Link]("dsn=your_dsn")

Output

record
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](connectionString as any, query as text, optional options as nullable record) as table

About
Returns the result of running query with the connection string connectionString using ODBC.
connectionString can be text or a record of property value pairs. Property values can either be text or number.
An optional record parameter, options , may be provided to specify additional properties. The record can
contain the following fields:
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is 15 seconds.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
SqlCompatibleWindowsAuth : A logical (true/false) that determines whether to produce SQL Server-compatible
connection string options for Windows authentication. The default value is true.

Example 1
Return the result of running a simple query against the provided connection string.
Usage

[Link]("dsn=your_dsn", "select * from Customers")

Output

table
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](connectionString as any, optional options as nullable record) as table

About
Returns a table of SQL tables and views from the OLE DB data source specified by the connection string
connectionString . connectionString can be text or a record of property value pairs. Property values can either
be text or number. An optional record parameter, options , may be provided to specify additional properties. The
record can contain the following fields:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is true).
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
SqlCompatibleWindowsAuth : A logical (true/false) that determines whether to produce SQL Server-compatible
connection string options for Windows authentication. The default value is true.
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](connectionString as any, query as text, optional options as nullable record) as
table

About
Returns the result of running query with the connection string connectionString using OLE DB.
connectionString can be text or a record of property value pairs. Property values can either be text or number.
An optional record parameter, options , may be provided to specify additional properties. The record can
contain the following fields:
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
SqlCompatibleWindowsAuth : A logical (true/false) that determines whether to produce SQL Server-compatible
connection string options for Windows authentication. The default value is true.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, optional options as nullable record) as table

About
Returns a table of SQL tables and views from the Oracle database on server server . The port may be optionally
specified with the server, separated by a colon. An optional record parameter, options , may be specified to
control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](pdf as binary, optional options as nullable record) as table

About
Returns any tables found in pdf . An optional record parameter, options , may be provided to specify additional
properties. The record can contain the following fields:
Implementation : The version of the algorithm to use when identifying tables. Old versions are available only
for backwards compatibility, to prevent old queries from being broken by algorithm updates. The newest
version should always give the best results. Valid values are "1.3", "1.2", "1.1", or null.
StartPage : Specifies the first page in the range of pages to examine. Default: 1.
EndPage : Specifies the last page in the range of pages to examine. Default: the last page of the document.
MultiPageTables : Controls whether similar tables on consecutive pages will be automatically combined into
a single table. Default: true.
EnforceBorderLines : Controls whether border lines are always enforced as cell boundaries (when true), or
simply used as one hint among many for determining cell boundaries (when false). Default: false.

Example 1
Returns the tables contained in [Link].
Usage

[Link]([Link]("c:\[Link]"))

Output

#table({"Name", "Kind", "Data"}, ...)


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record) as
table

About
Returns a table of SQL tables and views available in a PostgreSQL database on server server in the database
instance named database . The port may be optionally specified with the server, separated by a colon. An
optional record parameter, options , may be specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](stream as binary) as any

About
Returns a record of data frames from the RData file.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](optional loginUrl as any, optional options as nullable record) as table

About
Returns the objects on the Salesforce account provided in the credentials. The account will be connected through
the provided environment loginUrl . If no environment is provided then the account will connect to production
([Link] An optional record parameter, options , may be provided to specify additional
properties. The record can contain the following fields:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is false).
ApiVersion : The Salesforce API version to use for this query. When not specified, API version 29.0 is used.
Timeout : A duration that controls how long to wait before abandoning the request to the server. The default
value is source-specific.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](optional loginUrl as nullable text, optional options as nullable record) as
table

About
Returns the reports on the Salesforce account provided in the credentials. The account will be connected
through the provided environment loginUrl . If no environment is provided then the account will connect to
production ([Link] An optional record parameter, options , may be provided to specify
additional properties. The record can contain the following fields:
ApiVersion : The Salesforce API version to use for this query. When not specified, API version 29.0 is used.
Timeout : A duration that controls how long to wait before abandoning the request to the server. The default
value is source-specific.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, systemNumberOrSystemId as text, clientId as text,
optional optionsOrLogonGroup as any, optional options as nullable record) as table

About
Returns a table of InfoCubes and queries grouped by InfoArea from an SAP Business Warehouse instance at
server server with system number systemNumberOrSystemId and Client ID clientId . An optional record
parameter, optionsOrLogonGroup , may be specified to control options.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](**server** as text, optional **options** as nullable record) as table

About
Returns a table of multidimensional packages from the SAP HANA database server . An optional record
parameter, options , may be specified to control the following options:
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
Distribution : A SapHanaDistribution that sets the value of the "Distribution" property in the connection
string. Statement routing is the method of evaluating the correct server node of a distributed system before
statement execution. The default value is [Link] .
Implementation : Specifies the implementation of the SAP HANA connector to use.
EnableColumnBinding : Binds variables to the columns of a SAP HANA result set when fetching data. May
potentially improve performance at the cost of slightly higher memory utilization. The default value is false.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as table

About
Returns a table containing a row for each folder and document found at the specified SharePoint site, url . Each
row contains properties of the folder or file and a link to its content. options may be specified to control the
following options:
ApiVersion : A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this
site. When not specified, API version 14 is used. When Auto is specified, the server version will be
automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require
at least version 15.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as table

About
Returns a table containing a row for each document found at the specified SharePoint site, url , and subfolders.
Each row contains properties of the folder or file and a link to its content. options may be specified to control
the following options:
ApiVersion : A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this
site. When not specified, API version 14 is used. When Auto is specified, the server version will be
automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require
at least version 15.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as table

About
Returns a table containing a row for each List item found at the specified SharePoint list, url . Each row contains
properties of the List. options may be specified to control the following options:
ApiVersion : A number (14 or 15) or the text "Auto" that specifies the SharePoint API version to use for this
site. When not specified, API version 14 is used. When Auto is specified, the server version will be
automatically discovered if possible, otherwise version defaults to 14. Non-English SharePoint sites require
at least version 15.
Implementation
ViewMode
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text) as table

About
Returns a table from the contents at the specified URL url formatted according to the SODA 2.0 API. The URL
must point to a valid SODA-compliant source that ends in a .csv extension.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record) as table

About
Returns a table of SQL tables, views, and stored functions from the SQL Server database database on server
server . The port may be optionally specified with the server, separated by a colon or a comma. An optional
record parameter, options , may be specified to control the following options:
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
MaxDegreeOfParallelism : A number that sets the value of the "maxdop" query clause in the generated SQL
query.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
MultiSubnetFailover : A logical (true/false) that sets the value of the "MultiSubnetFailover" property in the
connection string (default is false).
UnsafeTypeConversions : A logical (true/false) that, if true, attempts to fold type conversions which could fail
and cause the entire query to fail. Not recommended for general use.
ContextInfo : A binary value that is used to set the CONTEXT_INFO before running each command.
OmitSRID : A logical (true/false) that, if true, omits the SRID when producing Well-Known Text from geometry
and geography types.
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, optional options as nullable record) as table

About
Returns a table of databases on the specified SQL server, server . An optional record parameter, options , may
be specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
MaxDegreeOfParallelism : A number that sets the value of the "maxdop" query clause in the generated SQL
query.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
MultiSubnetFailover : A logical (true/false) that sets the value of the "MultiSubnetFailover" property in the
connection string (default is false).
UnsafeTypeConversions : A logical (true/false) that, if true, attempts to fold type conversions which could fail
and cause the entire query to fail. Not recommended for general use.
ContextInfo : A binary value that is used to set the CONTEXT_INFO before running each command.
OmitSRID : A logical (true/false) that, if true, omits the SRID when producing Well-Known Text from geometry
and geography types.
The record parameter is specified as [option1 = value1, option2 = value2...] for example.
Does not support setting a SQL query to run on the server. [Link] should be used instead to run a SQL
query.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, database as text, optional options as nullable record) as table

About
Returns a table of SQL tables and views available in a Sybase database on server server in the database
instance named database . The port may be optionally specified with the server, separated by a colon. An
optional record parameter, options , may be specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on the
returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first will
be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation : A logical (true/false) that sets whether to view the tables grouped by their schema
names (default is false).
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](server as text, optional options as nullable record) as table

About
Returns a table of SQL tables and views from the Teradata database on server server . The port may be
optionally specified with the server, separated by a colon. An optional record parameter, options , may be
specified to control the following options:
CreateNavigationProperties : A logical (true/false) that sets whether to generate navigation properties on
the returned values (default is true).
NavigationPropertyNameGenerator : A function that is used for the creation of names for navigation
properties.
Query : A native SQL query used to retrieve data. If the query produces multiple result sets, only the first
will be returned.
CommandTimeout : A duration that controls how long the server-side query is allowed to run before it is
canceled. The default value is ten minutes.
ConnectionTimeout : A duration that controls how long to wait before abandoning an attempt to make a
connection to the server. The default value is driver-dependent.
HierarchicalNavigation: A logical (true/false) that sets whether to view the tables grouped by their
schema names (default is false).
The record parameter is specified as [option1 = value1, option2 = value2...] or [Query = "select ..."] for example.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](method as text, url as text, optional options as nullable record) as action

About
Creates an action that, when executed, will return the results of performing a method request against url using
HTTP as a binary value. An optional record parameter, options , may be provided to specify additional
properties. The record can contain the following fields:
Query : Programmatically add query parameters to the URL without having to worry about escaping.
ApiKeyName : If the target site has a notion of an API key, this parameter can be used to specify the name (not
the value) of the key parameter that must be used in the URL. The actual key value is provided in the
credential.
Headers : Specifying this value as a record will supply additional headers to an HTTP request.
Timeout : Specifying this value as a duration will change the timeout for an HTTP request. The default value is
100 seconds.
ExcludedFromCacheKey : Specifying this value as a list will exclude these HTTP header keys from being part of
the calculation for caching data.
IsRetry : Specifying this logical value as true will ignore any existing response in the cache when fetching
data.
ManualStatusHandling : Specifying this value as a list will prevent any builtin handling for HTTP requests
whose response has one of these status codes.
RelativePath : Specifying this value as text appends it to the base URL before making the request.
Content : Specifying this value will cause its contents to become the body of the HTTP request.

Note that this function is disabled in most contexts. Consider using [Link] or [Link] instead.

Example 1
Perform a GET request against Bing.
Usage

[Link]([Link], "[Link]

Output
Action
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as text

About
Returns the HTML for the specified url , as viewed by a web browser. An optional record parameter, options ,
may be provided to specify additional properties. The record can contain the following fields:
WaitFor : Specifies a condition to wait for before downloading the HTML, in addition to waiting for the page
to load (which is always done). Can be a record containing Timeout and/or Selector fields. If only a Timeout is
specified, the function will wait the amount of time specified before downloading the HTML. If both a Selector
and Timeout are specified, and the Timeout elapses before the Selector exists on the page, an error will be
thrown. If a Selector is specified with no Timeout, a default Timeout of 30 seconds is applied.

Example 1
Returns the HTML for [Link]
Usage

[Link]("[Link]

Output
"<!DOCTYPE html><html xmlns=..."

Example 2
Returns the HTML for [Link] after waiting for a CSS selector to exist.
Usage

[Link]("[Link] [WaitFor = [Selector = "[Link]"]])

Output
"<!DOCTYPE html><html xmlns=..."

Example 3
Returns the HTML for [Link] after waiting ten seconds.
Usage

[Link]("[Link] [WaitFor = [Timeout = #duration(0,0,0,10)]])


Output
"<!DOCTYPE html><html xmlns=..."

Example 4
Returns the HTML for [Link] after waiting up to ten seconds for a CSS selector to exist.
Usage

[Link]("[Link] [WaitFor = [Selector = "[Link]", Timeout =


#duration(0,0,0,10)]])

Output
"<!DOCTYPE html><html xmlns=..."
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as binary

About
Returns the contents downloaded from url as binary. An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
Query : Programmatically add query parameters to the URL without having to worry about escaping.
ApiKeyName : If the target site has a notion of an API key, this parameter can be used to specify the name (not
the value) of the key parameter that must be used in the URL. The actual key value is provided in the
credential.
Headers : Specifying this value as a record will supply additional headers to an HTTP request.
Timeout : Specifying this value as a duration will change the timeout for an HTTP request. The default value is
100 seconds.
ExcludedFromCacheKey : Specifying this value as a list will exclude these HTTP header keys from being part of
the calculation for caching data.
IsRetry : Specifying this logical value as true will ignore any existing response in the cache when fetching
data.
ManualStatusHandling : Specifying this value as a list will prevent any builtin handling for HTTP requests
whose response has one of these status codes.
RelativePath : Specifying this value as text appends it to the base URL before making the request.
Content : Specifying this value changes the web request from a GET to a POST, using the value of the option
as the content of the POST.
The HTTP request is made as either a GET (when no Content is specified) or a POST (when there is Content).
POST requests may only be made anonymously.
The headers of the HTTP response are available as metadata on the binary result. Outside of a custom data
connector context, only a subset of response headers is available (for security reasons).

Example 1
Retrieve the contents of "[Link] using the RelativePath and Query options.
These options can be used to dynamically query a static base URL.
Usage
let
searchText = "Power Query"
in
[Link](
"[Link]
[
RelativePath = "search",
Query = [q = searchText]
]
)

Output
binary

Example 2
Perform a POST against a URL, passing a binary JSON payload and parsing the response as JSON.
Usage

let
url = ...,
headers = [#"Content-Type" = "application/json"],
postData = [Link]([x = 235.7, y = 41.53]),
response = [Link](
url,
[
Headers = headers,
Content = postData
]
),
jsonResponse = [Link](response)
in
jsonResponse

Output
table

Example 3
Connect to a secure URL that accepts an authentication key as part of its query string. Instead of hard-coding
the secret key in M (which would pose a security risk), the key can be provided securely by specifying its name
(not its value) in M, choosing Web API authentication, and entering the key value as part of the Web API
credential. When used in this way, the following example will generate a request to
"[Link] .

Usage

[Link]("[Link] [ApiKeyName="api_key"])

Output
binary
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](url as text, optional options as nullable record) as record

About
Returns the headers downloaded from url as a record. An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
Query : Programmatically add query parameters to the URL without having to worry about escaping.
ApiKeyName : If the target site has a notion of an API key, this parameter can be used to specify the name (not
the value) of the key parameter that must be used in the URL. The actual key value is provided in the
credential.
Headers : Specifying this value as a record will supply additional headers to an HTTP request.
Timeout : Specifying this value as a duration will change the timeout for an HTTP request. The default value is
100 seconds.
ExcludedFromCacheKey : Specifying this value as a list will exclude these HTTP header keys from being part of
the calculation for caching data.
IsRetry : Specifying this logical value as true will ignore any existing response in the cache when fetching
data.
ManualStatusHandling : Specifying this value as a list will prevent any builtin handling for HTTP requests
whose response has one of these status codes.
RelativePath : Specifying this value as text appends it to the base URL before making the request.

The HTTP request is made with the HEAD method. Outside of a custom data connector context, only a subset of
response headers is available (for security reasons).

Example 1
Retrieve the HTTP headers for "[Link] using the RelativePath and Query
options.
Usage

let
searchText = "Power Query"
in
[Link](
"[Link]
[
RelativePath = "search",
Query = [q = searchText]
]
)

Output
([
#"Cache-Control" = "private, max-age=0",
#"Content-Encoding" = "gzip",
#"Content-Length" = "0",
#"Content-Type" = "text/html; charset=utf-8",
Date = "Tue, 14 Dec 2021 [Link] GMT",
Expires = "Tue, 14 Dec 2021 [Link] GMT",
Vary = "Accept-Encoding"
]
meta [
[Link] = 200
])
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](html as any) as table

About
Returns the contents of the HTML document broken into its constituent structures, as well as a representation of
the full document and its text after removing tags.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](contents as any, optional encoding as nullable number) as table

About
Returns the contents of the XML document as a hierarchical table.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](contents as any, optional options as nullable record, optional encoding as nullable
number) as table

About
Returns the contents of the XML document as a nested collection of flattened tables.

Example 1
Retrieve the contents of a local XML file.
Usage

[Link]([Link]("C:\[Link]"))

Output
table
Binary functions
9/13/2022 • 2 minutes to read

These functions create and manipulate binary data.

Binary Formats
Reading numbers
NAME DESC RIP T IO N

BinaryFormat.7BitEncodedSignedInteger A binary format that reads a 64-bit signed integer that was
encoded using a 7-bit variable-length encoding.

BinaryFormat.7BitEncodedUnsignedInteger A binary format that reads a 64-bit unsigned integer that


was encoded using a 7-bit variable-length encoding.

[Link] Returns a binary format that reads a binary value.

[Link] A binary format that reads an 8-bit unsigned integer.

[Link] Returns a binary format that chooses the next binary format
based on a value that has already been read.

[Link] A binary format that reads a .NET 16-byte decimal value.

[Link] A binary format that reads an 8-byte IEEE double-precision


floating point value.

[Link] Returns a binary format that reads a group of items. Each


item value is preceded by a unique key value. The result is a
list of item values.

[Link] Returns a binary format that limits the amount of data that
can be read. Both [Link] and
[Link] can be used to read until end of the
data. [Link] can be used to limit the number
of bytes that are read.

[Link] Returns a binary format that reads a sequence of items and


returns a list.

[Link] A binary format that reads zero bytes and returns null.

[Link] Returns a binary format that reads a record. Each field in the
record can have a different binary format.

BinaryFormat.SignedInteger16 A binary format that reads a 16-bit signed integer.

BinaryFormat.SignedInteger32 A binary format that reads a 32-bit signed integer.


NAME DESC RIP T IO N

BinaryFormat.SignedInteger64 A binary format that reads a 64-bit signed integer.

[Link] A binary format that reads a 4-byte IEEE single-precision


floating point value.

[Link] Returns a binary format that reads a text value. The optional
encoding value specifies the encoding of the text.

[Link] Returns a binary format that will transform the values read
by another binary format.

BinaryFormat.UnsignedInteger16 A binary format that reads a 16-bit unsigned integer.

BinaryFormat.UnsignedInteger32 A binary format that reads a 32-bit unsigned integer.

BinaryFormat.UnsignedInteger64 A binary format that reads a 64-bit unsigned integer.

Controlling byte order


NAME DESC RIP T IO N

[Link] Returns a binary format with the byte order specified by a


function.

[Link] Returns information about how a table is partitioned.

Binary data
NAME DESC RIP T IO N

[Link] Returns the approximate length of the binary.

[Link] Buffers the binary value in memory. The result of this call is a
stable binary value, which means it will have a deterministic
length and order of bytes.

[Link] Combines a list of binaries into a single binary.

[Link] Compresses a binary value using the given compression


type.

[Link] Decompresses a binary value using the given compression


type.

[Link] Returns a binary value from the given value.

[Link] Converts a list of numbers into a binary value

[Link] Decodes data from a text form into binary.


NAME DESC RIP T IO N

[Link] Returns a record with field [Link] that contains the


inferred MIME-type.

[Link] Returns the length of binary values.

[Link] Returns a subset of the binary value beginning at an offset.

[Link] Converts a binary value into a list of numbers

[Link] Encodes binary data into a text form.

[Link] Creates or extends a binary with user-defined handlers for


query and action operations.

[Link] Creates a modified error record which won't trigger a fallback


when thrown by a handler defined on a view (via
[Link]).

[Link] Creates a function that can be intercepted by a handler


defined on a view (via [Link] ).

#binary Creates a binary value from numbers or text.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary) as nullable number

About
Returns the approximate length of binary , or an error if the data source doesn't support an approximate length.

Example 1
Get the approximate length of the binary value.
Usage

[Link]([Link]("i45WMlSKjQUA", BinaryEncoding.Base64))

Output
9
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary) as nullable binary

About
Buffers the binary value in memory. The result of this call is a stable binary value, which means it will have a
deterministic length and order of bytes.

Example 1
Create a stable version of the binary value.
Usage

[Link]([Link]({0..10}))

Output
#binary({0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaries as list) as binary

About
Combines a list of binaries into a single binary.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary, compressionType as number) as nullable binary

About
Compresses a binary value using the given compression type. The result of this call is a compressed copy of the
input. Compression types include:
[Link]
[Link]

Example 1
Compress the binary value.
Usage

[Link]([Link]([Link]({10}, 1000)), [Link])

Output
#binary({227, 226, 26, 5, 163, 96, 20, 12, 119, 0, 0})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary, compressionType as number) as nullable binary

About
Decompresses a binary value using the given compression type. The result of this call is a decompressed copy
of the input. Compression types include:
[Link]
[Link]

Example 1
Decompress the binary value.
Usage

[Link](#binary({115, 103, 200, 7, 194, 20, 134, 36, 134, 74, 134, 84, 6, 0}),
[Link])

Output
#binary({71, 0, 111, 0, 111, 0, 100, 0, 98, 0, 121, 0, 101, 0})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional encoding as nullable number) as nullable binary

About
Returns a binary value from the given value . If the given value is null , Binar [Link] returns null . If the
given value is binary , value is returned. Values of the following types can be converted to a binary value:
text :A binary value from the text representation. Refer to [Link] for details.
If value is of any other type, an error is returned.

Example 1
Get the binary value of "1011" .
Usage

[Link]("1011")

Output
[Link]("1011", BinaryEncoding.Base64)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as binary

About
Converts a list of numbers into a binary value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional encoding as nullable number) as nullable binary

About
Returns the result of converting text value text to a binary (list of number ). encoding may be specified to
indicate the encoding used in the text value. The following BinaryEncoding values may be used for encoding .
BinaryEncoding.Base64: Base 64 encoding
[[Link]]([Link]: Hex encoding

Example 1
Decode "1011" into binary.
Usage

[Link]("1011")

Output

[Link]("1011", BinaryEncoding.Base64)

Example 2
Decode "1011" into binary with Hex encoding.
Usage

[Link]("1011", [Link])

Output

[Link]("EBE=", BinaryEncoding.Base64)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](source as binary) as record

About
Returns a record with field [Link] that contains the inferred MIME-type. If the inferred content type is
text/*, and an encoding code page is detected, then additionally returns field [Link] that contains the
encoding of the stream. If the inferred content type is text/csv, and the format is delimited, additionally returns
field [Link] containing a table for analysis of potential delimiters. If the inferred content type is
text/csv, and the format is fixed-width, additionally returns field [Link] containing a list for
analysis of potential fixed width column positions.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary) as nullable number

About
Returns the number of characters.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary, offset as number, optional count as nullable number) as binary

About
Returns a subset of the binary value beginning at the offset binary . An optional parameter, offset , sets the
maximum length of the subset.

Example 1
Returns a subset of the binary value starting at offset 6.
Usage

[Link](#binary({0..10}), 6)

Output
#binary({6, 7, 8, 9, 10})

Example 2
Returns a subset of length 2 from offset 6 of the binary value.
Usage

[Link](#binary({0..10}), 6, 2)

Output
#binary({6, 7})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary) as list

About
Converts a binary value into a list of numbers.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary, optional encoding as nullable number) as nullable text

About
Returns the result of converting a binary list of numbers binary into a text value. Optionally, encoding may be
specified to indicate the encoding to be used in the text value produced The following BinaryEncoding values
may be used for encoding .
BinaryEncoding.Base64 : Base 64 encoding
[Link] : Hex encoding
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary, handlers as record) as binary

About
Returns a view of binary where the functions specified in handlers are used in lieu of the default behavior of
an operation when the operation is applied to the view.
If binary is provided, all handler functions are optional. If binary isn't provided, the GetStream handler
function is required. If a handler function isn't specified for an operation, the default behavior of the operation is
applied to binary instead (except in the case of GetExpression ).
Handler functions must return a value that is semantically equivalent to the result of applying the operation
against binary (or the resulting view in the case of GetExpression ).
If a handler function raises an error, the default behavior of the operation is applied to the view.
[Link] can be used to implement folding to a data source–the translation of M queries into source-
specific operations (for example, to download a section of a file).
Refer to the published Power Query custom connector documentation for a more complete description of
[Link] .

Example 1
Create a basic view that doesn't require accessing the data in order to determine the length.
Usage

[Link](
null,
[
GetLength = () => 12,
GetStream = () => [Link]("hello world!")
]
)

Output

[Link]("hello world!")
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](errorRecord as record) as record

About
Creates a modified error record from errorRecord which won't trigger a fallback when thrown by a handler
defined on a view (via [Link]).
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function) as function

About
Creates a view function based on function that can be handled in a view created by [Link].
The OnInvoke handler of [Link] can be used to defined a handler for the view function.
As with the handlers for built-in operations, if no OnInvoke handler is specified, or if it does not handle the view
function, or if an error is raised by the handler, function is applied on top of the view.
Refer to the published Power Query custom connector documentation for a more complete description of
[Link] and custom view functions.
BinaryFormat.7BitEncodedSignedInteger
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.7BitEncodedSignedInteger(binary as binary) as any

About
A binary format that reads a 64-bit signed integer that was encoded using a 7-bit variable-length encoding.
BinaryFormat.7BitEncodedUnsignedInteger
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.7BitEncodedUnsignedInteger(binary as binary) as any

About
A binary format that reads a 64-bit unsigned integer that was encoded using a 7-bit variable-length encoding.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](optional length as any) as function

About
Returns a binary format that reads a binary value. If length is specified, the binary value will contain that many
bytes. If length is not specified, the binary value will contain the remaining bytes. The length can be specified
either as a number, or as a binary format of the length that preceeds the binary data.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary) as any

About
A binary format that reads an 8-bit unsigned integer.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaryFormat as function, byteOrder as number) as function

About
Returns a binary format with the byte order specified by binaryFormat . The default byte order is
[Link] .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaryFormat as function, chooseFunction as function, optional type as
nullable type, optional combineFunction as nullable function) as function

About
Returns a binary format that chooses the next binary format based on a value that has already been read. The
binary format value produced by this function works in stages:
The binary format specified by the binaryFormat parameter is used to read a value.
The value is passed to the choice function specified by the chooseFunction parameter.
The choice function inspects the value and returns a second binary format.
The second binary format is used to read a second value.
If the combine function is specified, then the first and second values are passed to the combine function, and
the resulting value is returned.
If the combine function is not specified, the second value is returned.
The second value is returned.
The optional type parameter indicates the type of binary format that will be returned by the choice function.
Either type any , type list , or type binary may be specified. If the type parameter is not specified, then
type any is used. If type list or type binary is used, then the system may be able to return a streaming
binary or list value instead of a buffered one, which may reduce the amount of memory necessary to read
the format.

Example 1
Read a list of bytes where the number of elements is determined by the first byte.
Usage

let
binaryData = #binary({2, 3, 4, 5}),
listFormat = [Link](
[Link],
(length) => [Link]([Link], length)
)
in
listFormat(binaryData)

Output
{3,4}

Example 2
Read a list of bytes where the number of elements is determined by the first byte, and preserve the first byte
read.
Usage

let
binaryData = #binary({2, 3, 4, 5}),
listFormat = [Link](
[Link],
(length) => [Link]([
length = length,
list = [Link]([Link], length)
])
)
in
listFormat(binaryData)

Output
[length = 2, list = {3, 4}]

Example 3
Read a list of bytes where the number of elements is determined by the first byte using a streaming list.
Usage

let
binaryData = #binary({2, 3, 4, 5}),
listFormat = [Link](
[Link],
(length) => [Link]([Link], length),
type list
)
in
listFormat(binaryData)

Output
{3, 4}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary) as any

About
A binary format that reads a .NET 16-byte decimal value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary) as any

About
A binary format that reads an 8-byte IEEE double-precision floating point value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaryFormat as function, group as list, optional extra as nullable function,
optional lastKey as any) as function

About
The parameters are as follows:
The binaryFormat parameter specifies the binary format of the key value.
The group parameter provides information about the group of known items.
The optional extra parameter can be used to specify a function that will return a binary format value for the
value following any key that was unexpected. If the extra parameter is not specified, then an error will be
raised if there are unexpected key values.
The group parameter specifies a list of item definitions. Each item definition is a list, containing 3-5 values, as
follows:
Key value. The value of the key that corresponds to the item. This must be unique within the set of items.
Item format. The binary format corresponding to the value of the item. This allows each item to have a
different format.
Item occurrence. The [Link] value for how many times the item is expected to appear in the
group. Required items that are not present cause an error. Required or optional duplicate items are handled
like unexpected key values.
Default item value (optional). If the default item value appears in the item definition list and is not null, then it
will be used instead of the default. The default for repeating or optional items is null, and the default for
repeating values is an empty list { }.
Item value transform (optional). If the item value transform function is present in the item definition list and
is not null, then it will be called to transform the item value before it is returned. The transform function is
only called if the item appears in the input (it will never be called with the default value).

Example 1
The following assumes a key value that is a single byte, with 4 expected items in the group, all of which have a
byte of data following the key. The items appear in the input as follows:
Key 1 is required, and does appear with value 11.
Key 2 repeats, and appears twice with value 22, and results in a value of { 22, 22 }.
Key 3 is optional, and does not appear, and results in a value of null.
Key 4 repeats, but does not appear, and results in a value of { }.
Key 5 is not part of the group, but appears once with value 55. The extra function is called with the key value
5, and returns the format corresponding to that value ([Link]). The value 55 is read and
discarded.
Usage
let
b = #binary({
1, 11,
2, 22,
2, 22,
5, 55,
1, 11
}),
f = [Link](
[Link],
{
{1, [Link], [Link]},
{2, [Link], [Link]},
{3, [Link], [Link]},
{4, [Link], [Link]}
},
(extra) => [Link]
)
in
f(b)

Output
{11, {22, 22}, null, {}}

Example 2
The following example illustrates the item value transform and default item value. The repeating item with key 1
sums the list of values read using [Link]. The optional item with key 2 has a default value of 123 instead of
null.
Usage

let
b = #binary({
1, 101,
1, 102
}),
f = [Link](
[Link],
{
{1, [Link], [Link],
0, (list) => [Link](list)},
{2, [Link], [Link], 123}
}
)
in
f(b)

Output
{203, 123}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaryFormat as function, length as any) as function

About
Returns a binary format that limits the amount of data that can be read. Both [Link] and
[Link] can be used to read until end of the data. [Link] can be used to limit the
number of bytes that are read. The binaryFormat parameter specifies the binary format to limit. The length
parameter specifies the number of bytes to read. The length parameter may either be a number value, or a
binary format value that specifies the format of the length value that appears that precedes the value being
read.

Example 1
Limit the number of bytes read to 2 when reading a list of bytes.
Usage

let
binaryData = #binary({1, 2, 3}),
listFormat = [Link](
[Link]([Link]),
2
)
in
listFormat(binaryData)

Output
{1, 2}

Example 2
Limit the number of byte read when reading a list of bytes to the byte value preceding the list.
Usage

let
binaryData = #binary({1, 2, 3}),
listFormat = [Link](
[Link]([Link]),
[Link]
)
in
listFormat(binaryData)

Output
{2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaryFormat as function, optional countOrCondition as any) as function

About
Returns a binary format that reads a sequence of items and returns a list . The binaryFormat parameter
specifies the binary format of each item. There are three ways to determine the number of items read:
If the countOrCondition is not specified, then the binary format will read until there are no more items.
If the countOrCondition is a number, then the binary format will read that many items.
If the countOrCondition is a function, then that function will be invoked for each item read. The function
returns true to continue, and false to stop reading items. The final item is included in the list.
If the countOrCondition is a binary format, then the count of items is expected to precede the list, and the
specified format is used to read the count.

Example 1
Read bytes until the end of the data.
Usage

let
binaryData = #binary({1, 2, 3}),
listFormat = [Link]([Link])
in
listFormat(binaryData)

Output
{1, 2, 3}

Example 2
Read two bytes.
Usage

let
binaryData = #binary({1, 2, 3}),
listFormat = [Link]([Link], 2)
in
listFormat(binaryData)

Output
{1, 2}
Example 3
Read bytes until the byte value is greater than or equal to two.
Usage

let
binaryData = #binary({1, 2, 3}),
listFormat = [Link]([Link], (x) => x < 2)
in
listFormat(binaryData)

Output
{1, 2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary) as any

About
A binary format that reads zero bytes and returns null.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record) as function

About
Returns a binary format that reads a record. The record parameter specifies the format of the record. Each field
in the record can have a different binary format. If a field contains a value that is not a binary format value, then
no data is read for that field, and the field value is echoed to the result.

Example 1
Read a record containing one 16-bit integer and one 32-bit integer.
Usage

let
binaryData = #binary({
0x00, 0x01,
0x00, 0x00, 0x00, 0x02
}),
recordFormat = [Link]([
A = BinaryFormat.UnsignedInteger16,
B = BinaryFormat.UnsignedInteger32
])
in
recordFormat(binaryData)

Output
[A = 1, B = 2]
BinaryFormat.SignedInteger16
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.SignedInteger16(binary as binary) as any

About
A binary format that reads a 16-bit signed integer.
BinaryFormat.SignedInteger32
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.SignedInteger32(binary as binary) as any

About
A binary format that reads a 32-bit signed integer.
BinaryFormat.SignedInteger64
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.SignedInteger64(binary as binary) as any

About
A binary format that reads a 64-bit signed integer.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary) as any

About
A binary format that reads a 4-byte IEEE single-precision floating point value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](length as any, optional encoding as nullable number) as function

About
Returns a binary format that reads a text value. The length specifies the number of bytes to decode, or the
binary format of the length that precedes the text. The optional encoding value specifies the encoding of the
text. If the encoding is not specified, then the encoding is determined from the Unicode byte order marks. If no
byte order marks are present, then TextEncoding.Utf8 is used.

Example 1
Decode two bytes as ASCII text.
Usage

let
binaryData = #binary({65, 66, 67}),
textFormat = [Link](2, [Link])
in
textFormat(binaryData)

Output
"AB"

Example 2
Decode ASCII text where the length of the text in bytes appears before the text as a byte.
Usage

let
binaryData = #binary({2, 65, 66}),
textFormat = [Link](
[Link],
[Link]
)
in
textFormat(binaryData)

Output
"AB"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binaryFormat as function, function as function) as function

About
Returns a binary format that will transform the values read by another binary format. The binaryFormat
parameter specifies the binary format that will be used to read the value. The function is invoked with the
value read, and returns the transformed value.

Example 1
Read a byte and add one to it.
Usage

let
binaryData = #binary({1}),
transformFormat = [Link](
[Link],
(x) => x + 1
)
in
transformFormat(binaryData)

Output
2
BinaryFormat.UnsignedInteger16
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.UnsignedInteger16(binary as binary) as any

About
A binary format that reads a 16-bit unsigned integer.
BinaryFormat.UnsignedInteger32
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.UnsignedInteger32(binary as binary) as any

About
A binary format that reads a 32-bit unsigned integer.
BinaryFormat.UnsignedInteger64
9/13/2022 • 2 minutes to read

Syntax
BinaryFormat.UnsignedInteger64(binary as binary) as any

About
A binary format that reads a 64-bit unsigned integer.
#binary
9/13/2022 • 2 minutes to read

Syntax
#binary(value as any) as any

About
Creates a binary value from a list of numbers or a base 64 encoded text value.

Example 1
Create a binary value from a list of numbers.
Usage

#binary({0x30, 0x31, 0x32})

Output
[Link]("012")

Example 2
Create a binary value from a base 64 encoded text value.
Usage

#binary("1011")

Output
[Link]("1011", BinaryEncoding.Base64)
Combiner functions
9/13/2022 • 2 minutes to read

These functions are used by other library functions that merge values. For example, [Link] and
[Link] apply a combiner function to each row in a table to produce a single value for each row.

NAME DESC RIP T IO N

[Link] Returns a function that combines a list of text into a single


text using the specified delimiter.

[Link] Returns a function that combines a list of text into a single


text using each specified delimiter in sequence.

[Link] Returns a function that combines a list of text into a single


text using the specified lengths.

[Link] Returns a function that combines a list of text into a single


text using the specified positions.

[Link] Returns a function that combines a list of text into a single


text using the specified positions and lengths.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](delimiter as text, optional quoteStyle as nullable number) as
function

About
Returns a function that combines a list of text into a single text using the specified delimiter.

Example 1
Combine a list of text values using a semicolon delimiter.
Usage

[Link](";")({"a", "b", "c"})

Output
"a;b;c"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](delimiters as list, optional quoteStyle as nullable number)
as function

About
Returns a function that combines a list of text into a single text using each specified delimiter in sequence.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lengths as list, optional template as nullable text) as function

About
Returns a function that combines a list of text into a single text using the specified lengths.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](positions as list, optional template as nullable text) as
function

About
Returns a function that combines a list of text into a single text using the specified positions.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](ranges as list, optional template as nullable text) as function

About
Returns a function that combines a list of text into a single text using the specified positions and lengths. A null
length indicates that the entire text value should be included.
Comparer functions
9/13/2022 • 2 minutes to read

These functions test equality and determine ordering.

NAME DESC RIP T IO N

[Link] Returns a logical value based on the equality check over the
two given values.

[Link] Returns a comparer function given the culture and a logical


value for case sensitivity for the comparison. The default
value for ignoreCase is false. The value for culture are well
known text representations of locales used in the .NET
framework.

[Link] Returns a comparer function which uses Ordinal rules to


compare values.

[Link] Returns a case-insensitive comparer function which uses


Ordinal rules to compare the provided values x and y.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](comparer as function, x as any, y as any) as logical

About
Returns a logical value based on the equality check over the two given values, x and y , using the provided
comparer .
comparer is a Comparer which is used to control the comparison. Comparers can be used to provide case-
insensitive or culture and locale-aware comparisons.
The following built-in comparers are available in the formula language:
[Link] : Used to perform an exact ordinal comparison
[Link] : Used to perform an exact ordinal case-insensitive comparison
[Link] : Used to perform a culture-aware comparison

Example 1
Compare "1" and "A" using "en-US" locale to determine if the values are equal.
Usage

[Link]([Link]("en-US"), "1", "A")

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](culture as text, optional ignoreCase as nullable logical) as function

About
Returns a comparer function given the culture and a logical value ignoreCase for case sensitivity for the
comparison. The default value for ignoreCase is false. The value for culture are well known text representations
of locales used in the .NET framework.

Example 1
Compare "a" and "A" using "en-US" locale to determine if the values are equal.
Usage

[Link]("en-US")("a", "A")

Output
-1

Example 2
Compare "a" and "A" using "en-US" locale ignoring the case to determine if the values are equal.
Usage

[Link]("en-US", true)("a", "A")

Output
0
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](x as any, y as any) as number

About
Returns a comparer function which uses Ordinal rules to compare the provided values x and y .

Example 1
Using Ordinal rules, compare if "encyclopædia" and "encyclopaedia" are equivalent. Note these are equivalent
using [Link]("en-US") .
Usage

[Link]([Link], "encyclopædia", "encyclopaedia")

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](x as any, y as any) as number

About
Returns a case-insensitive comparer function which uses Ordinal rules to compare the provided values x and
y .

Example 1
Using case-insensitive Ordinal rules, compare "Abc" with "abc". Note "Abc" is less than "abc" using
[Link] .

Usage

[Link]("Abc", "abc")

Output
0
Date functions
9/13/2022 • 5 minutes to read

These functions create and manipulate the date component of date, datetime, and datetimezone values.

NAME DESC RIP T IO N

[Link] Returns a Date/DateTime/DateTimeZone value with the day


portion incremented by the number of days provided. It also
handles incrementing the month and year potions of the
value as appropriate.

[Link] Returns a DateTime value with the month portion


incremented by n months.

[Link] Returns a Date/DateTime/DateTimeZone value incremented


by the number of quarters provided. Each quarter is defined
as a duration of three months. It also handles incrementing
the year potion of the value as appropriate.

[Link] Returns a Date/DateTime/DateTimeZone value incremented


by the number of weeks provided. Each week is defined as a
duration of seven days. It also handles incrementing the
month and year potions of the value as appropriate.

[Link] Returns a DateTime value with the year portion incremented


by n years.

[Link] Returns the day for a DateTime value.

[Link] Returns a number (from 0 to 6) indicating the day of the


week of the provided value.

[Link] Returns the day of the week name.

[Link] Returns a number that represents the day of the year from a
DateTime value.

[Link] Returns the number of days in the month from a DateTime


value.

[Link] Returns a DateTime value for the end of the day.

[Link] Returns a DateTime value for the end of the month.

[Link] Returns a Date/DateTime/DateTimeZone value representing


the end of the quarter. The date and time portions are reset
to their terminating values for the quarter. The timezone
information is persisted.

[Link] Returns a DateTime value for the end of the week.


NAME DESC RIP T IO N

[Link] Returns a DateTime value for the end of the year.

[Link] Returns a date value from a value.

[Link] Creates a Date from local, universal, and custom Date


formats.

[Link] Indicates whether the given datetime value dateTime


occurs during the current day, as determined by the current
date and time on the system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the current
month, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the current
quarter, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the current
week, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the current
year, as determined by the current date and time on the
system.

[Link] Indicates whether the given datetime value dateTime occurs


during the next day, as determined by the current date and
time on the system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the next
month, as determined by the current date and time on the
system.

[Link] Indicates whether the given datetime value dateTime occurs


during the next number of days, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the next number of months, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the next number of quarters, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the next number of weeks, as determined by the
current date and time on the system.
NAME DESC RIP T IO N

[Link] Indicates whether the given datetime value dateTime occurs


during the next number of years, as determined by the
current date and time on the system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the next
quarter, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the next
week, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the next
year, as determined by the current date and time on the
system.

[Link] Indicates whether the given datetime value dateTime occurs


during the previous day, as determined by the current date
and time on the system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the previous
month, as determined by the current date and time on the
system.

[Link] Indicates whether the given datetime value dateTime occurs


during the previous number of days, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the previous number of months, as determined by
the current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the previous number of quarters, as determined by
the current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the previous number of weeks, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value dateTime occurs


during the previous number of years, as determined by the
current date and time on the system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the previous
quarter, as determined by the current date and time on the
system.
NAME DESC RIP T IO N

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the previous
week, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred during the previous
year, as determined by the current date and time on the
system.

[Link] Returns a logical value indicating whether the given


Date/DateTime/DateTimeZone occurred in the period
starting January 1st of the current year and ending on the
current day, as determined by the current date and time on
the system.

[Link] Returns a logical value indicating whether the year portion of


a DateTime value is a leap year.

[Link] Returns the month from a DateTime value.

[Link] Returns the name of the month component.

[Link] Returns a number between 1 and 4 for the quarter of the


year from a DateTime value.

[Link] Returns a DateTime value for the start of the day.

[Link] Returns a DateTime value representing the start of the


month.

[Link] Returns a DateTime value representing the start of the


quarter.

[Link] Returns a DateTime value representing the start of the week.

[Link] Returns a DateTime value representing the start of the year.

[Link] Returns a record containing parts of a Date value.

[Link] Returns a text value from a Date value.

[Link] Returns a number for the count of week in the current


month.

[Link] Returns a number for the count of week in the current year.

[Link] Returns the year from a DateTime value.

#date Creates a date value from year, month, and day.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, numberOfDays as number) as any

About
Returns the date , datetime , or datetimezone result from adding numberOfDays days to the datetime value
dateTime .

dateTime : The date , datetime , or datetimezone value to which days are being added.
numberOfDays : The number of days to add.

Example 1
Add 5 days to the date , datetime , or datetimezone value representing the date 5/14/2011.
Usage

[Link](#date(2011, 5, 14), 5)

Output
#date(2011, 5, 19)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, numberOfMonths as number) as any

About
Returns the date , datetime , or datetimezone result from adding numberOfMonths months to the datetime
value dateTime .
dateTime : The , datetime , or datetimezone value to which months are being added.
date
numberOfMonths : The number of months to add.

Example 1
Add 5 months to the date , datetime , or datetimezone value representing the date 5/14/2011.
Usage

[Link](#date(2011, 5, 14), 5)

Output
#date(2011, 10, 14)

Example 2
Add 18 months to the date , datetime , or datetimezone value representing the date and time of 5/14/2011
[Link] AM.
Usage

[Link](#datetime(2011, 5, 14, 8, 15, 22), 18)

Output
#datetime(2012, 11, 14, 8, 15, 22)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, numberOfQuarters as number) as any

About
Returns the date , datetime , or datetimezone result from adding numberOfQuarters quarters to the datetime
value dateTime .
dateTime : The , datetime , or datetimezone value to which quarters are being added.
date
numberOfQuarters : The number of quarters to add.

Example 1
Add 1 quarter to the date , datetime , or datetimezone value representing the date 5/14/2011.
Usage

[Link](#date(2011, 5, 14), 1)

Output
#date(2011, 8, 14)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, numberOfWeeks as number) as any

About
Returns the date , datetime , or datetimezone result from adding numberOfWeeks weeks to the datetime value
dateTime .

dateTime : The , datetime , or datetimezone value to which weeks are being added.
date
numberOfWeeks : The number of weeks to add.

Example 1
Add 2 weeks to the date , datetime , or datetimezone value representing the date 5/14/2011.
Usage

[Link](#date(2011, 5, 14), 2)

Output
#date(2011, 5, 28)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, numberOfYears as number) as any

About
Returns the date , datetime , or datetimezone result of adding numberOfYears to a datetime value dateTime .
dateTime : The , datetime , or datetimezone value to which years are added.
date
numberOfYears : The number of years to add.

Example 1
Add 4 years to the date , datetime , or datetimezone value representing the date 5/14/2011.
Usage

[Link](#date(2011, 5, 14), 4)

Output
#date(2015, 5, 14)

Example 2
Add 10 years to the date , datetime , or datetimezone value representing the date and time of 5/14/2011
[Link] AM.
Usage

[Link](#datetime(2011, 5, 14, 8, 15, 22), 10)

Output
#datetime(2021, 5, 14, 8, 15, 22)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns the day component of a date , datetime , or datetimezone value.
dateTime :A date , datetime , or datetimezone value from which the day component is extracted.

Example 1
Get the day component of a date , datetime , or datetimezone value representing the date and time of
5/14/2011 [Link] PM.
Usage

[Link](#datetime(2011, 5, 14, 17, 0, 0))

Output
14
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, optional firstDayOfWeek as nullable number) as nullable number

About
Returns a number (from 0 to 6) indicating the day of the week of the provided dateTime .
dateTime :A date , , or datetimezone value.
datetime
firstDayOfWeek : A Day value indicating which day should be considered the first day of the week. Allowed
values are [Link], [Link], [Link], [Link], [Link], [Link], or
[Link]. If unspecified, a culture-dependent default is used.

Example 1
Get the day of the week represented by Monday, February 21st, 2011, treating Sunday as the first day of the
week.
Usage

[Link](#date(2011, 02, 21), [Link])`

Output
1

Example 2
Get the day of the week represented by Monday, February 21st, 2011, treating Monday as the first day of the
week.
Usage

[Link](#date(2011, 02, 21), [Link])

Output
0
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](date as any, optional culture as nullable text)

About
Returns the day of the week name for the provided date . An optional culture may also be provided (for
example, "en-US").

Example 1
Get the day of the week name.
Usage

[Link](#date(2011, 12, 31), "en-US")

Output
"Saturday"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns a number representing the day of the year in the provided date , datetime , or datetimezone value,
dateTime .

Example 1
The number of the day March 1st, 2011 ( #date(2011, 03, 01) ).
Usage

[Link](#date(2011, 03, 01))

Output
60
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns the number of days in the month in the date , datetime , or datetimezone value dateTime .
dateTime :A date , datetime , or datetimezone value for which the number of days in the month is returned.

Example 1
Number of days in the month December as represented by #date(2011, 12, 01) .
Usage

[Link](#date(2011, 12, 01))

Output
31
[Link]
9/13/2022 • 2 minutes to read

[Link](dateTime as any) as any

About
Returns a date , datetime , or datetimezone value representing the end of the day in dateTime . Time zone
information is preserved.
dateTime :A date , datetime , or datetimezone value from from which the end of the day is calculated.

Example 1
Get the end of the day for 5/14/2011 [Link] PM.
Usage

[Link](#datetime(2011, 5, 14, 17, 0, 0))

Output
#datetime(2011, 5, 14, 23, 59, 59.9999999)

Example 2
Get the end of the day for 5/17/2011 [Link] PM -7:00.
Usage

[Link](#datetimezone(2011, 5, 17, 5, 0, 0, -7, 0))

Output
#datetimezone(2011, 5, 17, 23, 59, 59.9999999, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns the last day of the month in dateTime .
dateTime :A date , datetime , or datetimezone value from which the end of the month is calculated

Example 1
Get the end of the month for 5/14/2011.
Usage

[Link](#date(2011, 5, 14))

Output
#date(2011, 5, 31)

Example 2
Get the end of the month for 5/17/2011 [Link] PM -7:00.
Usage

[Link](#datetimezone(2011, 5, 17, 5, 0, 0, -7, 0))

Output
#datetimezone(2011, 5, 31, 23, 59, 59.9999999, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns a date , datetime , or datetimezone value representing the end of the quarter in dateTime . Time zone
information is preserved.
dateTime :A date , datetime , or datetimezone value from which the end of the quarter is calculated.

Example 1
Find the end of the quarter for October 10th, 2011, 8:00AM ( #datetime(2011, 10, 10, 8, 0, 0) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 0, 0))

Output
#datetime(2011, 12, 31, 23, 59, 59.9999999)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, optional firstDayOfWeek as nullable number) as any

About
Returns the last day of the week in the provided date , datetime , or datetimezone dateTime . This function
takes an optional Day , firstDayOfWeek , to set the first day of the week for this relative calculation. The default
value is [Link].
dateTime :A , datetime , or datetimezone value from which the last day of the week is calculated
date
firstDayOfWeek : [Optional] A [Link] value representing the first day of the week. Possible values are
[Link] , [Link] , [Link] , [Link] , [Link] , [Link] , and [Link] . The
default value is [Link] .

Example 1
Get the end of the week for 5/14/2011.
Usage

[Link](#date(2011, 5, 14))

Output
#date(2011, 5, 14)

Example 2
Get the end of the week for 5/17/2011 [Link] PM -7:00, with Sunday as the first day of the week.
Usage

[Link](#datetimezone(2011, 5, 17, 5, 0, 0, -7, 0), [Link])

Output
#datetimezone(2011, 5, 21, 23, 59, 59.9999999, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns a value representing the end of the year in dateTime , including fractional seconds. Time zone
information is preserved.
dateTime :A date , datetime , or datetimezone value from which the end of the year is calculated.

Example 1
Get the end of the year for 5/14/2011 [Link] PM.
Usage

[Link](#datetime(2011, 5, 14, 17, 0, 0))

Output
#datetime(2011, 12, 31, 23, 59, 59.9999999)

Example 2
Get the end of hour for 5/17/2011 [Link] PM -7:00.
Usage

[Link](#datetimezone(2011, 5, 17, 5, 0, 0, -7, 0))

Output
#datetimezone(2011, 12, 31, 23, 59, 59.9999999, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable date

About
Returns a date value from the given value . An optional culture > may also be provided (for example, "en-
US"). If the given value is null , [Link] returns null . If the given value is date , value is returned.
Values of the following types can be converted to a date value:
text :A value from textual representation. Refer to [Link] for details.
date
datetime : The date component of the value .
datetimezone : The date component of the local datetime equivalent of value .
number : The date component of the datetime equivalent of the OLE Automation Date expressed by value .
If value is of any other type, an error is returned.

Example 1
Convert 43910 to a date value.
Usage

[Link](43910)

Output
#date(2020, 3, 20)

Example 2
Convert #datetime(1899, 12, 30, 06, 45, 12) to a date value.
Usage

[Link](#datetime(1899, 12, 30, 06, 45, 12))

Output
#date(1899, 12, 30)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional options as any) as nullable date

About
Creates a date value from a textual representation, text . An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in parsing the date using a best effort.
Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"MMM" is "Jan", "Feb", "Mar", ... , while in "ru-RU" "MMM" is "янв", "фев", "мар", ... . When Format
is null , Culture controls the default format to use. When Culture is null or omitted, [Link]
is used.
To support legacy workflows, options may also be a text value. This has the same behavior as if
options = [Format = null, Culture = options] .

Example 1
Convert "2010-12-31" into a date value.
Usage

[Link]("2010-12-31")

Output
#date(2010, 12, 31)

Example 2
Convert using a custom format and the German culture.
Usage

[Link]("30 Dez 2010", [Format="dd MMM yyyy", Culture="de-DE"])

Output
#date(2010, 12, 30)

Example 3
Find the date in the Gregorian calendar that corresponds to the beginning of 1400 in the Hijri calendar.
Usage

[Link]("1400", [Format="yyyy", Culture="ar-SA"])

Output
#date(1979, 11, 20)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current day, as determined by the
current date and time on the system.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example
Determine if the current system time is in the current day.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current month, as determined by the
current date and time on the system.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current month.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current quarter, as determined by the
current date and time on the system.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current quarter.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current week, as determined by the
current date and time on the system.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current week.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current year, as determined by the
current date and time on the system.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current year.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next day, as determined by the current
date and time on the system. Note that this function will return false when passed a value that occurs within the
current day.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the day after the current system time is in the next day.
Usage

[Link]([Link]([Link](), 1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next month, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current month.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the month after the current system time is in the next month.
Usage

[Link]([Link]([Link](), 1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, days as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of days, as determined by
the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current day.
dateTime : A date , datetime , or datetimezone value to be evaluated.
days : The number of days.

Example 1
Determine if the day after the current system time is in the next two days.
Usage

[Link]([Link]([Link](), 1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

[Link](dateTime as any, months as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of months, as determined
by the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current month.
dateTime : A date , datetime , or datetimezone value to be evaluated.
months : The number of months.

Example 1
Determine if the month after the current system time is in the next two months.
Usage

[Link]([Link]([Link](), 1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, quarters as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of quarters, as determined
by the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current quarter.
dateTime : A date , datetime , or datetimezone value to be evaluated.
quarters : The number of quarters.

Example 1
Determine if the quarter after the current system time is in the next two quarters.
Usage

[Link]([Link]([Link](), 1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, weeks as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of weeks, as determined
by the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current week.
dateTime : A date , datetime , or datetimezone value to be evaluated.
weeks : The number of weeks.

Example 1
Determine if the week after the current system time is in the next two weeks.
Usage

[Link]([Link]([Link](), 7), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, years as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of years, as determined by
the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current year.
dateTime : A date , datetime , or datetimezone value to be evaluated.
years : The number of years.

Example 1
Determine if the year after the current system time is in the next two years.
Usage

[Link]([Link]([Link](), 1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next quarter, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current quarter.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the quarter after the current system time is in the next quarter.
Usage

[Link]([Link]([Link](), 1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next week, as determined by the current
date and time on the system. Note that this function will return false when passed a value that occurs within the
current week.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the week after the current system time is in the next week.
Usage

[Link]([Link]([Link](), 7))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next year, as determined by the current
date and time on the system. Note that this function will return false when passed a value that occurs within the
current year.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the year after the current system time is in the next year.
Usage

[Link]([Link]([Link](), 1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous day, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current day.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the day before the current system time is in the previous day.
Usage

[Link]([Link]([Link](), -1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous month, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current month.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the month before the current system time is in the previous month.
Usage

[Link]([Link]([Link](), -1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, days as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of days, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current day.
dateTime : A date , datetime , or datetimezone value to be evaluated.
`days: The number of days.

Example 1
Determine if the day before the current system time is in the previous two days.
Usage

[Link]([Link]([Link](), -1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, months as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of months, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current month.
dateTime : A date , datetime , or datetimezone value to be evaluated.
months : The number of months.

Example 1
Determine if the month before the current system time is in the previous two months.
Usage

[Link]([Link]([Link](), -1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, quarters as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of quarters, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current quarter.
dateTime : A date , datetime , or datetimezone value to be evaluated.
quarters : The number of quarters.

Example 1
Determine if the quarter before the current system time is in the previous two quarters.
Usage

[Link]([Link]([Link](), -1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, weeks as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of weeks, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current week.
dateTime : A date , datetime , or datetimezone value to be evaluated.
weeks : The number of weeks.

Example 1
Determine if the week before the current system time is in the previous two weeks.
Usage

[Link]([Link]([Link](), -7), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, years as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of years, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current year.
dateTime : A date , datetime , or datetimezone value to be evaluated.
years : The number of years.

Example 1
Determine if the year before the current system time is in the previous two years.
Usage

[Link]([Link]([Link](), -1), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous quarter, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current quarter.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the quarter before the current system time is in the previous quarter.
Usage

[Link]([Link]([Link](), -1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous week, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current week.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the week before the current system time is in the previous week.
Usage

[Link]([Link]([Link](), -7))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous year, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current year.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the year before the current system time is in the previous year.
Usage

[Link]([Link]([Link](), -1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current year and is on or before the
current day, as determined by the current date and time on the system.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the year to date.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime falls in is a leap year.
dateTime :A date , datetime , or datetimezone value to be evaluated.

Example 1
Determine if the year 2012, as represented by #date(2012, 01, 01) is a leap year.
Usage

[Link](#date(2012, 01, 01))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns the month component of the provided datetime value, dateTime .

Example 1
Find the month in #datetime(2011, 12, 31, 9, 15, 36).
Usage

[Link](#datetime(2011, 12, 31, 9, 15, 36))

Output
12
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](date as any, optional culture as nullable text) as nullable text

About
Returns the name of the month component for the provided date . An optional culture may also be provided
(for example, "en-US").

Example 1
Get the month name.
Usage

[Link](#datetime(2011, 12, 31, 5, 0, 0), "en-US")

Output
"December"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns a number from 1 to 4 indicating which quarter of the year the date dateTime falls in. dateTime can be a
date , datetime , or datetimezone value.

Example 1
Find which quarter of the year the date #date(2011, 12, 31) falls in.
Usage

[Link](#date(2011, 12, 31))

Output
4
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns the first value of the day dateTime . dateTime must be a date , datetime , or datetimezone value.

Example 1
Find the start of the day for October 10th, 2011, 8:00AM ( #datetime(2011, 10, 10, 8, 0, 0) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 0, 0))

Output
#datetime(2011, 10, 10, 0, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns the first value of the month given a date or datetime type.

Example 1
Find the start of the month for October 10th, 2011, [Link]M ( #datetime(2011, 10, 10, 8, 10, 32) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 10, 32))

Output
#datetime(2011, 10, 1, 0, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns the first value of the quarter < dateTime . dateTime must be a date , datetime , or datetimezone value.

Example 1
Find the start of the quarter for October 10th, 2011, 8:00AM ( #datetime(2011, 10, 10, 8, 0, 0) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 0, 0))

Output
#datetime(2011, 10, 1, 0, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, optional firstDayOfWeek as nullable number) as any

About
Returns the first value of the week given a date , datetime , or datetimezone value.

Example 1
Find the start of the week for October 10th, 2011, [Link]M ( #datetime(2011, 10, 10, 8, 10, 32) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 10, 32))

Output
#datetime(2011, 10, 9, 0, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns the first value of the year given a date , datetime , or datetimezone value.

Example 1
Find the start of the year for October 10th, 2011, [Link]M ( #datetime(2011, 10, 10, 8, 10, 32) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 10, 32))

Output
#datetime(2011, 1, 1, 0, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](date as date) as record

About
Returns a record containing the parts of the given date value, date .
date :A date value for from which the record of its parts is to be calculated.

Example 1
Convert the #date(2011, 12, 31) value into a record containing parts from the date value.
Usage

[Link](#date(2011, 12, 31))

Output

[
Year = 2011,
Month = 12,
Day = 31
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](date as nullable date, optional options as any, optional culture as nullable text)
as nullable text

About
Returns a textual representation of date . An optional record parameter, options , may be provided to specify
additional properties. culture is only used for legacy workflows. The record can contain the following fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in formatting the date using the default defined by
Culture .

Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"MMM" is "Jan", "Feb", "Mar", ... , while in "ru-RU" "MMM" is "янв", "фев", "мар", ... . When Format
is null , Culture controls the default format to use. When Culture is null or omitted, [Link]
is used.
To support legacy workflows, options and culture may also be text values. This has the same behavior as if
options = [Format = options, Culture = culture] .

Example 1
Convert #date(2010, 12, 31) into a text value. Result output may vary depending on current culture.
Usage

[Link](#date(2010, 12, 31))

Output
"12/31/2010"

Example 2
Convert using a custom format and the German culture.
Usage

[Link](#date(2010, 12, 31), [Format="dd MMM yyyy", Culture="de-DE"])

Output
"31 Dez 2010"
Example 3
Find the year in the Hijri calendar that corresponds to January 1st, 2000 in the Gregorian calendar.
Usage

[Link](#date(2000, 1, 1), [Format="yyyy", Culture="ar-SA"])

Output
"1420"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, optional firstDayOfWeek as nullable number) as nullable number

About
Returns a number from 1 to 6 indicating which week of the month the date dateTime falls in.
dateTime :A datetime value for which the week-of-the-month is determined.

Example 1
Determine which week of March the 15th falls on in 2011 ( #date(2011, 03, 15) ).
Usage

[Link](#date(2011, 03, 15))

Output
3
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, optional firstDayOfWeek as nullable number) as nullable number

About
Returns a number from 1 to 54 indicating which week of the year the date, dateTime , falls in.
dateTime :A datetime value for which the week-of-the-year is determined.
firstDayOfWeek: An optional [Link] value that indicates which day is considered the start of a new
week (for example, [Link] ). If unspecified, a culture-dependent default is used.

Example 1
Determine which week of the year March 27th, 2011 falls in ( #date(2011, 03, 27) ).
Usage

[Link](#date(2011, 03, 27))

Output
14

Example 2
Determine which week of the year March 27th, 2011 falls in ( #date(2011, 03, 27) ), using Monday as the start
of a new week.
Usage

[Link](#date(2011, 03, 27), [Link])

Output
13
[Link]
9/13/2022 • 2 minutes to read

[Link](dateTime as any) as nullable number

About
Returns the year component of the provided datetime value, dateTime .

Example 1
Find the year in #datetime(2011, 12, 31, 9, 15, 36).
Usage

[Link](#datetime(2011, 12, 31, 9, 15, 36))

Output
2011
#date
9/13/2022 • 2 minutes to read

Syntax
#date(year as number, month as number, day as number) as date

About
Creates a date value from whole numbers representing the year, month, and day. Raises an error if these
conditions are not true:
1 ≤ year ≤ 9999
1 ≤ month ≤ 12
1 ≤ day ≤ 31
DateTime functions
9/13/2022 • 2 minutes to read

These functions create and manipulate datetime and datetimezone values.

NAME DESC RIP T IO N

[Link] Adds the timezonehours as an offset to the input datetime


value and returns a new datetimezone value.

[Link] Returns a date part from a DateTime value

[Link] Returns a DateTime value set to the current date and time
on the system.

[Link] Returns a datetime value from a value.

[Link] Returns a DateTime value from the supplied number.

[Link] Creates a datetime from local and universal datetime


formats.

[Link] Indicates whether the given datetime value occurs during


the current hour, as determined by the current date and
time on the system.

[Link] Indicates whether the given datetime value occurs during


the current minute, as determined by the current date and
time on the system.

[Link] Indicates whether the given datetime value occurs during


the current second, as determined by the current date and
time on the system.

[Link] Indicates whether the given datetime value occurs during


the next hour, as determined by the current date and time
on the system.

[Link] Indicates whether the given datetime value occurs during


the next minute, as determined by the current date and time
on the system.

[Link] Indicates whether the given datetime value occurs during


the next number of hours, as determined by the current
date and time on the system.

[Link] Indicates whether the given datetime value occurs during


the next number of minutes, as determined by the current
date and time on the system.
NAME DESC RIP T IO N

[Link] Indicates whether the given datetime value occurs during


the next number of seconds, as determined by the current
date and time on the system.

[Link] Indicates whether the given datetime value occurs during


the next second, as determined by the current date and time
on the system.

[Link] Indicates whether the given datetime value occurs during


the previous hour, as determined by the current date and
time on the system.

[Link] Indicates whether the given datetime value occurs during


the previous minute, as determined by the current date and
time on the system.

[Link] Indicates whether the given datetime value occurs during


the previous number of hours, as determined by the current
date and time on the system.

[Link] Indicates whether the given datetime value occurs during


the previous number of minutes, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value occurs during


the previous number of seconds, as determined by the
current date and time on the system.

[Link] Indicates whether the given datetime value occurs during


the previous second, as determined by the current date and
time on the system.

[Link] Returns a datetime value set to the current date and time on
the system.

[Link] Returns a time part from a DateTime value.

[Link] Returns a record containing parts of a DateTime value.

[Link] Returns a text value from a DateTime value.

#datetime Creates a datetime value from year, month, day, hour,


minute, and second.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as nullable datetime, timezoneHours as number, optional
timezoneMinutes as nullable number) as nullable datetimezone

About
Sets timezone information to on the datetime value dateTime . The timezone information will include
timezoneHours and optionally timezoneMinutes .

Example 1
Set timezone information for #datetime(2010, 12, 31, 11, 56, 02) to 7 hours, 30 minutes.
Usage

[Link](#datetime(2010, 12, 31, 11, 56, 02), 7, 30)

Output
#datetimezone(2010, 12, 31, 11, 56, 2, 7, 30)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable date

About
Returns the date component of dateTime , the given date , datetime , or datetimezone value.

Example 1
Find date value of #datetime(2010, 12, 31, 11, 56, 02).
Usage

[Link](#datetime(2010, 12, 31, 11, 56, 02))

Output
#date(2010, 12, 31)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as datetime

About
Returns a datetime value set to the current date and time on the system. This value is fixed and will not change
with successive calls, unlike [Link], which may return different values over the course of execution
of an expression.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable datetime

About
Returns a datetime value from the given value . An optional culture may also be provided (for example, "en-
US"). If the given value is null , [Link] returns null . If the given value is datetime , value is
returned. Values of the following types can be converted to a datetime value:
text :A datetimevalue from textual representation. Refer to [Link] for details.
date : A datetime with value as the date component and [Link] AM as the time component.
datetimezone : The local datetime equivalent of value .
time : A datetime with the date equivalent of the OLE Automation Date of 0 as the date component and
value as the time component.
number : A datetime equivalent of the OLE Automation Date expressed by value .

If value is of any other type, an error is returned.

Example 1
Convert #time(06, 45, 12) to a datetime value.
Usage

[Link](#time(06, 45, 12))

Output
#datetime(1899, 12, 30, 06, 45, 12)

Example 2
Convert #date(1975, 4, 4) to a datetime value.
Usage

[Link](#date(1975, 4, 4))

Output
#datetime(1975, 4, 4, 0, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](fileTime as nullable number) as nullable datetime

About
Creates a datetime value from the fileTime value and converts it to the local time zone. The filetime is a
Windows file time value that represents the number of 100-nanosecond intervals that have elapsed since 12:00
midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

Example 1
Convert 129876402529842245 into a datetime value.
Usage

[Link](129876402529842245)

Output
#datetime(2012, 7, 24, 14, 50, 52.9842245)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional options as any) as nullable datetime

About
Creates a datetime value from a textual representation, text . An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in parsing the date using a best effort.
Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"MMM" is "Jan", "Feb", "Mar", ... , while in "ru-RU" "MMM" is "янв", "фев", "мар", ... . When Format
is null , Culture controls the default format to use. When Culture is null or omitted, [Link]
is used.
To support legacy workflows, options may also be a text value. This has the same behavior as if
options = [Format = null, Culture = options] .

Example 1
Convert "2010-12-31T[Link]" into a datetime value.
Usage

[Link]("2010-12-31T[Link]")

Output
#datetime(2010, 12, 31, 1, 30, 25)

Example 2
Convert "2010-12-31T[Link].121212" into a datetime value.
Usage

[Link]("30 Dez 2010 [Link].369730", [Format="dd MMM yyyy HH:mm:[Link]", Culture="de-DE"])

Output
#datetime(2010, 12, 30, 2, 4, 50.36973)

Example 3
Convert "2010-12-31T[Link]" into a datetime value.
Usage

[Link]("2000-02-08T[Link]Z", [Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"])

Output
#datetime(2000, 2, 8, 3, 45, 12)

Example 4
Convert "20101231T013000" into a datetime value.
Usage

[Link]("20101231T013000", [Format="yyyyMMdd'T'HHmmss", Culture="en-US"])

Output
#datetime(2010, 12, 31, 1, 30, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current hour, as determined by the
current date and time on the system.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current hour.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current minute, as determined by the
current date and time on the system.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current minute.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the current second, as determined by the
current date and time on the system.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the current system time is in the current second.
Usage

[Link]([Link]())

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next hour, as determined by the current
date and time on the system. Note that this function will return false when passed a value that occurs within the
current hour.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the hour after the current system time is in the next hour.
Usage

[Link]([Link]() + #duration(0, 1, 0, 0))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next minute, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current minute.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the minute after the current system time is in the next minute.
Usage

[Link]([Link]() + #duration(0, 0, 1, 0))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, hours as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of hours, as determined by
the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current hour.
dateTime : A datetime , or datetimezone value to be evaluated.
hours : The number of hours.

Example 1
Determine if the hour after the current system time is in the next two hours.
Usage

[Link]([Link]() + #duration(0, 2, 0, 0), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, minutes as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of minutes, as determined
by the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current minute.
dateTime : A datetime , or datetimezone value to be evaluated.
minutes : The number of minutes.

Example 1
Determine if the minute after the current system time is in the next two minutes.
Usage

[Link]([Link]() + #duration(0, 0, 2, 0), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, seconds as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next number of seconds, as determined
by the current date and time on the system. Note that this function will return false when passed a value that
occurs within the current second.
dateTime : A datetime , or datetimezone value to be evaluated.
seconds : The number of seconds.

Example 1
Determine if the second after the current system time is in the next two seconds.
Usage

[Link]([Link]() + #duration(0, 0, 0, 2), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the next second, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current second.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the second after the current system time is in the next second.
Usage

[Link]([Link]() + #duration(0, 0, 0, 1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous hour, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current hour.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the hour before the current system time is in the previous hour.
Usage

[Link]([Link]() - #duration(0, 1, 0, 0))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous minute, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current minute.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the minute before the current system time is in the previous minute.
Usage

[Link]([Link]() - #duration(0, 0, 1, 0))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, hours as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of hours, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current hour.
dateTime : A datetime , or datetimezone value to be evaluated.
hours : The number of hours.

Example 1
Determine if the hour before the current system time is in the previous two hours.
Usage

[Link]([Link]() - #duration(0, 2, 0, 0), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, minutes as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of minutes, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current minute.
dateTime : A datetime , or datetimezone value to be evaluated.
`minutes: The number of minutes.

Example 1
Determine if the minute before the current system time is in the previous two minutes.
Usage

[Link]([Link]() - #duration(0, 0, 2, 0), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any, seconds as number) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous number of seconds, as
determined by the current date and time on the system. Note that this function will return false when passed a
value that occurs within the current second.
dateTime : A datetime >, or datetimezone value to be evaluated.
seconds : The number of seconds.

Example 1
Determine if the second before the current system time is in the previous two seconds.
Usage

[Link]([Link]() - #duration(0, 0, 0, 2), 2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable logical

About
Indicates whether the given datetime value dateTime occurs during the previous second, as determined by the
current date and time on the system. Note that this function will return false when passed a value that occurs
within the current second.
dateTime :A datetime , or datetimezone value to be evaluated.

Example 1
Determine if the second before the current system time is in the previous second.
Usage

[Link]([Link]() - #duration(0, 0, 0, 1))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as datetime

About
Returns a datetime value set to the current date and time on the system.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable time

About
Returns the time part of the given datetime value, dateTime .

Example 1
Find the time value of #datetime(2010, 12, 31, 11, 56, 02).
Usage

[Link](#datetime(2010, 12, 31, 11, 56, 02))

Output
#time(11, 56, 2)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as datetime) as record

About
Returns a record containing the parts of the given datetime value, dateTime .
dateTime :A datetime value for from which the record of its parts is to be calculated.

Example 1
Convert the #datetime(2011, 12, 31, 11, 56, 2) value into a record containing Date and Time values.
Usage

[Link](#datetime(2011, 12, 31, 11, 56, 2))

Output

[
Year = 2011,
Month = 12,
Day = 31,
Hour = 11,
Minute = 56,
Second = 2
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as nullable datetime, optional options as any, optional culture as
nullable text) as nullable text

About
Returns a textual representation of dateTime . An optional record parameter, options , may be provided to
specify additional properties. culture is only used for legacy workflows. The record can contain the following
fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in formatting the date using the default defined by
Culture .

Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"MMM" is "Jan", "Feb", "Mar", ... , while in "ru-RU" "MMM" is "янв", "фев", "мар", ... . When Format
is null , Culture controls the default format to use. When Culture is null or omitted, [Link]
is used.
To support legacy workflows, options and culture may also be text values. This has the same behavior as if
options = [Format = options, Culture = culture] .

Example 1
Convert #datetime(2010, 12, 31, 01, 30, 25) into a text value. Result output may vary depending on current
culture.
Usage

[Link](#datetime(2010, 12, 31, 01, 30, 25))

Output
"12/31/2010 [Link] AM"

Example 2
Convert using a custom format and the German culture.
Usage

[Link](#datetime(2010, 12, 30, 2, 4, 50.36973), [Format="dd MMM yyyy HH:mm:[Link]", Culture="de-


DE"])

Output
"30 Dez 2010 [Link].369730"

Example 3
Convert using the ISO 8601 pattern.
Usage

[Link](#datetime(2000, 2, 8, 3, 45, 12),[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"])

Output
"2000-02-08T[Link]Z"
#datetime
9/13/2022 • 2 minutes to read

Syntax
#datetime(year as number, month as number, day as number, hour as number, minute as number,
second as number) as datetime

About
Creates a datetime value from numbers representing the year, month, day, hour, minute, and (fractional) second.
Raises an error if these conditions are not true:
1 ≤ year ≤ 9999
1 ≤ month ≤ 12
1 ≤ day ≤ 31
0 ≤ hour ≤ 23
0 ≤ minute ≤ 59
0 ≤ second < 60
DateTimeZone functions
9/13/2022 • 2 minutes to read

These functions create and manipulate datetimezone values.

NAME DESC RIP T IO N

[Link] Returns a DateTimeZone value set to the current date, time,


and timezone offset on the system.

[Link] Returns the current date and time in UTC (the GMT
timezone).

[Link] Returns a datetimezone value from a value.

[Link] Returns a DateTimeZone from a number value.

[Link] Creates a datetimezone from local, universal, and custom


datetimezone formats.

[Link] Returns a DateTime value set to the current system date and
time.

[Link] Returns a datetime value with the zone information removed


from the input datetimezone value.

[Link] Changes the timezone information for the input


DateTimeZone.

[Link] Returns a DateTime value from the local time zone.

[Link] Returns a record containing parts of a DateTime value.

[Link] Returns a text value from a DateTime value.

[Link] Returns a DateTime value to the Utc time zone.

[Link] Returns a DateTime value set to the current system date and
time in the Utc timezone.

[Link] Returns a time zone hour value from a DateTime value.

[Link] Returns a time zone minute value from a DateTime value.

#datetimezone Creates a datetimezone value from year, month, day, hour,


minute, second, offset-hours, and offset-minutes.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as datetimezone

About
Returns a datetime value set to the current date and time on the system. The returned value contains timezone
information representing the local timezone. This value is fixed and will not change with successive calls, unlike
[Link], which may return different values over the course of execution of an expression.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as datetimezone

About
Returns the current date and time in UTC (the GMT timezone). This value is fixed and will not change with
successive calls.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable datetimezone

About
Returns a datetimezone value from the given value . An optional culture may also be provided (for example,
"en-US"). If the given value is null , [Link] returns null . If the given value is datetimezone ,
value is returned. Values of the following types can be converted to a datetimezone value:

text : A datetimezone value from textual representation. Refer to [Link] for details.
date : A datetimezone with value as the date component, [Link] AM as the time component, and the
offset corresponding the local time zone.
datetime : A datetimezone with value as the datetime and the offset corresponding the local time zone.
time : A datetimezone with the date equivalent of the OLE Automation Date of 0 as the date component,
value as the time component, and the offset corresponding the local time zone.
number : A datetimezone with the datetime equivalent to the OLE Automation Date expressed by value and
the offset corresponding the local time zone.
If value is of any other type, an error is returned.

Example 1
Convert "2020-10-30T[Link]-08:00" to a datetimezone value.
Usage

[Link]("2020-10-30T[Link]-08:00")

Output
#datetimezone(2020, 10, 30, 01, 30, 00, -8, 00)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](fileTime as nullable number) as nullable datetimezone

About
Creates a datetimezone value from the fileTime value and converts it to the local time zone. The filetime is a
Windows file time value that represents the number of 100-nanosecond intervals that have elapsed since 12:00
midnight, January 1, 1601 A.D. (C.E.) Coordinated Universal Time (UTC).

Example 1
Convert 129876402529842245 into a datetimezone value.
Usage

[Link](129876402529842245)

Output
#datetimezone(2012, 7, 24, 14, 50, 52.9842245, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional options as any) as nullable datetimezone

About
Creates a datetimezone value from a textual representation, text . An optional record parameter, options ,
may be provided to specify additional properties. The record can contain the following fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in parsing the date using a best effort.
Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"MMM" is "Jan", "Feb", "Mar", ... , while in "ru-RU" "MMM" is "янв", "фев", "мар", ... . When Format
is null , Culture controls the default format to use. When Culture is null or omitted, [Link]
is used.
To support legacy workflows, options may also be a text value. This has the same behavior as if
options = [Format = null, Culture = options] .

Example 1
Convert "2010-12-31T[Link]-08:00" into a datetimezone value.
Usage

[Link]("2010-12-31T[Link]-08:00")

Output
#datetimezone(2010, 12, 31, 1, 30, 0, -8, 0)

Example 2
Convert using a custom format and the German culture.
Usage

[Link]("30 Dez 2010 [Link].369730 +02:00", [Format="dd MMM yyyy HH:mm:[Link] zzz",
Culture="de-DE"])

Output
#datetimezone(2010, 12, 30, 2, 4, 50.36973, 2, 0)

Example 3
Convert using ISO 8601.
Usage

[Link]("2009-06-15T[Link].0000000-07:00", [Format="O", Culture="en-US"])

Output
#datetimezone(2009, 6, 15, 13, 45, 30, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as datetimezone

About
Returns a datetimezone value set to the current date and time on the system. The returned value contains
timezone information representing the local timezone.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone) as nullable datetime

About
Returns a #datetime value from dateTimeZone with timezone information removed.

Example 1
Remove timezone information from the value #datetimezone(2011, 12, 31, 9, 15, 36, -7, 0).
Usage

[Link](#datetimezone(2011, 12, 31, 9, 15, 36, -7, 0))

Output
#datetime(2011, 12, 31, 9, 15, 36)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone, timezoneHours as number, optional
timezoneMinutes as nullable number) as nullable datetimezone

About
Changes timezone information to on the datetimezone value dateTimeZone to the new timezone information
provided by timezoneHours and optionally timezoneMinutes . If dateTimeZone does not have a timezone
component, an exception is thrown.

Example 1
Change timezone information for #datetimezone(2010, 12, 31, 11, 56, 02, 7, 30) to 8 hours.
Usage

[Link](#datetimezone(2010, 12, 31, 11, 56, 02, 7, 30), 8)

Output
#datetimezone(2010, 12, 31, 12, 26, 2, 8, 0)

Example 2
Change timezone information for #datetimezone(2010, 12, 31, 11, 56, 02, 7, 30) to -30 minutes.
Usage

[Link](#datetimezone(2010, 12, 31, 11, 56, 02, 7, 30), 0, -30)

Output
#datetimezone(2010, 12, 31, 3, 56, 2, 0, -30)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone) as nullable datetimezone

About
Changes timezone information of the datetimezone value dateTimeZone to the local timezone information. If
dateTimeZone does not have a timezone component, the local timezone information is added.

Example 1
Change timezone information for #datetimezone(2010, 12, 31, 11, 56, 02, 7, 30) to local timezone (assuming
PST).
Usage

[Link](#datetimezone(2010, 12, 31, 11, 56, 02, 7, 30))

Output
#datetimezone(2010, 12, 31, 12, 26, 2, -8, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as datetimezone) as record

About
Returns a record containing the parts of the given datetimezone value, dateTimeZone .
dateTimeZone :A datetimezone value for from which the record of its parts is to be calculated.

Example 1
Convert the #datetimezone(2011, 12, 31, 11, 56, 2, 8, 0) value into a record containing Date, Time, and Zone
values.
Usage

[Link](#datetimezone(2011, 12, 31, 11, 56, 2, 8, 0))

Output

[
Year = 2011,
Month = 12,
Day = 31,
Hour = 11,
Minute = 56,
Second = 2,
ZoneHours = 8,
ZoneMinutes = 0
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone, optional options as any, optional
culture as nullable text) as nullable text

About
Returns a textual representation of dateTimeZone . An optional record parameter, options , may be provided to
specify additional properties. culture is only used for legacy workflows. The record can contain the following
fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in formatting the date using the default defined by
Culture .

Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"MMM" is "Jan", "Feb", "Mar", ... , while in "ru-RU" "MMM" is "янв", "фев", "мар", ... . When Format
is null , Culture controls the default format to use. When Culture is null or omitted, [Link]
is used.
To support legacy workflows, options and culture may also be text values. This has the same behavior as if
options = [Format = options, Culture = culture] .

Example 1
Convert #datetimezone(2010, 12, 31, 01, 30, 25, 2, 0) into a text value. Result output may vary depending
on current culture.
Usage

[Link](#datetimezone(2010, 12, 31, 01, 30, 25, 2, 0))

Output
"12/31/2010 [Link] AM +02:00"

Example 2
Convert using a custom format and the German culture.
Usage

[Link](#datetimezone(2010, 12, 30, 2, 4, 50.36973, -8,0), [Format="dd MMM yyyy HH:mm:[Link]


zzz", Culture="de-DE"])

Output
"30 Dez 2010 [Link].369730 -08:00"

Example 3
Convert using the ISO 8601 pattern.
Usage

[Link](#datetimezone(2000, 2, 8, 3, 45, 12, 2, 0),[Format="O", Culture="en-US"])

Output
"2000-02-08T[Link].0000000+02:00"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone) as nullable datetimezone

About
Changes timezone information of the datetime value dateTimeZone to the UTC or Universal Time timezone
information. If dateTimeZone does not have a timezone component, the UTC timezone information is added.

Example 1
Change timezone information for #datetimezone(2010, 12, 31, 11, 56, 02, 7, 30) to UTC timezone.
Usage

[Link](#datetimezone(2010, 12, 31, 11, 56, 02, 7, 30))

Output
#datetimezone(2010, 12, 31, 4, 26, 2, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as datetimezone

About
Returns the current date and time in UTC (the GMT timezone).

Example 1
Get the current date & time in UTC.
Usage

[Link]()

Output
#datetimezone(2011, 8, 16, 23, 34, 37.745, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone) as nullable number

About
Changes the timezone of the value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTimeZone as nullable datetimezone) as nullable number

About
Changes the timezone of the value.
#datetimezone
9/13/2022 • 2 minutes to read

Syntax
#datetimezone(year as number, month as number, day as number, hour as number, minute as number,
second as number, offsetHours as number, offsetMinutes as number) as datetimezone

About
Creates a datetimezone value from numbers representing the year, month, day, hour, minute, (fractional) second,
(fractional) offset-hours, and offset-minutes. Raises an error if these conditions are not true:
1 ≤ year ≤ 9999
1 ≤ month ≤ 12
1 ≤ day ≤ 31
0 ≤ hour ≤ 23
0 ≤ minute ≤ 59
0 ≤ second < 60
-14 ≤ offset-hours + offset-minutes / 60 ≤ 14
Duration functions
9/13/2022 • 2 minutes to read

These functions create and manipulate duration values.

NAME DESC RIP T IO N

[Link] Returns the days portion of a duration.

[Link] Returns a duration value from a value.

[Link] Returns a Duration value from a text value.

[Link] Returns the hours portion of a duration.

[Link] Returns the minutes portion of a duration.

[Link] Returns the seconds portion of a duration.

[Link] Returns a record with parts of a Duration value.

[Link] Returns the total magnitude of days from a Duration value.

[Link] Returns the total magnitude of hours from a Duration value.

[Link] Returns the total magnitude of minutes from a Duration


value.

[Link] Returns the total magnitude of seconds from a duration


value.

[Link] Returns a text value from a Duration value.

#duration Creates a duration value from days, hours, minutes, and


seconds.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the days portion of duration .

Example 1
Extract the days from a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as nullable duration

About
Returns a duration value from the given value . If the given value is null , [Link] returns null . If
the given value is duration , value is returned. Values of the following types can be converted to a duration
value:
text : A duration value from textual elapsed time forms (d.h:m:s). Refer to [Link] for details.
number : A duration equivalent to the number of whole and fractional days expressed by value .

If value is of any other type, an error is returned.

Example 1
Convert 2.525 into a duration value.
Usage

[Link](2.525)

Output
#duration(2, 12, 36, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text) as nullable duration

About
Returns a duration value from the specified text, text . The following formats can be parsed by this function:
(-)hh:mm(:ss(.ff))
(-)ddd(.hh:mm(:ss(.ff)))
(All ranges are inclusive)
ddd: Number of days.
hh: Number of hours, between 0 and 23.
mm: Number of minutes, between 0 and 59.
ss: Number of seconds, between 0 and 59.
ff: Fraction of seconds, between 0 and 9999999.

Example 1
Convert "2.[Link]" into a duration value.
Usage

[Link]("2.[Link]")

Output
#duration(2, 5, 55, 20)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the hours portion of duration .

Example 1
Extract the hours from a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
4
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the minutes portion of duration .

Example 1
Extract the minutes from a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
3
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the seconds portion of duration .

Example 1
Extract the seconds from a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
2
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as duration) as record

About
Returns a record containing the parts the duration value, duration .
duration :A duration from which the record is created.

Example 1
Convert #duration(2, 5, 55, 20) into a record of its parts including days, hours, minutes, and seconds if
applicable.
Usage

[Link](#duration(2, 5, 55, 20))

Output

[
Days = 2,
Hours = 5,
Minutes = 55,
Seconds = 20
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the total days spanned by duration .

Example 1
Find the total days spanned by a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
5.1687731481481478
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the total hours spanned by duration .

Example 1
Find the total hours spanned by a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
124.05055555555555
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the total minutes spanned by duration .

Example 1
Find the total minutes spanned by a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
7443.0333333333338
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration) as nullable number

About
Returns the total seconds spanned by duration .

Example 1
Find the total seconds spanned by a duration value.
Usage

[Link](#duration(5, 4, 3, 2))

Output
446582
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](duration as nullable duration, optional format as nullable text) as nullable
text

About
Returns a textual representation in the form "[Link]:mins:sec" of the given duration value, duration .
duration : A duration from which the textual representation is calculated.
format : [Optional] Deprecated, will throw an error if not null.

Example 1
Convert #duration(2, 5, 55, 20) into a text value.
Usage

[Link](#duration(2, 5, 55, 20))

Output
"2.[Link]"
#duration
9/13/2022 • 2 minutes to read

Syntax
#duration(days as number, hours as number, minutes as number, seconds as number) as duration

About
Creates a duration value from numbers representing days, hours, minutes, and (fractional) seconds.
Error handling functions
9/13/2022 • 2 minutes to read

These functions can be used to trace or construct errors.

NAME DESC RIP T IO N

[Link] Returns an opaque identifier for the currently-running


evaluation.

[Link] Writes a trace message, if tracing is enabled, and returns


value.

[Link] Returns a record containing fields Reason , Message , and


Detail set to the provided values. The record can be used to
raise or throw an error.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as nullable text

About
Returns an opaque identifier for the currently-running evaluation.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](traceLevel as number, message as anynonnull, value as any, optional delayed as
nullable logical) as any

About
Writes a trace message , if tracing is enabled, and returns value . An optional parameter delayed specifies
whether to delay the evaluation of value until the message is traced. traceLevel can take one of the following
values:
[Link]
[Link]
[Link]
[Link]
[Link]

Example 1
Trace the message before invoking [Link] function and return the result.
Usage

[Link]([Link], "TextValueFromNumber", () => [Link](123), true)

Output
"123"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](reason as text, optional message as nullable text, optional detail as any, optional
parameters as nullable list) as record

About
Returns an error record from the provided text values for reason, message and detail.
Expression functions
9/13/2022 • 2 minutes to read

These functions allow the construction and evaluation of M code.

NAME DESC RIP T IO N

[Link] Returns the M source code representation of a constant


value.

[Link] Returns the result of evaluating an M expression.

[Link] Returns the M source code representation of an identifier.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as text

About
Returns the M source code representation of a constant value.

Example 1
Get the M source code representation of a number value.
Usage

[Link](123)

Output
"123"

Example 2
Get the M source code representation of a date value.
Usage

[Link](#date(2035, 01, 02))

Output
"#date(2035, 1, 2)"

Example 3
Get the M source code representation of a text value.
Usage

[Link]("abc")

Output
"""abc"""
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](document as text, optional environment as nullable record) as any

About
Returns the result of evaluating an M expression document , with the available identifiers that can be referenced
defined by environment .

Example 1
Evaluate a simple sum.
Usage

[Link]("1 + 1")

Output
2

Example 2
Evaluate a more complex sum.
Usage

[Link]("[Link]({1, 2, 3})", [[Link] = [Link]])

Output
6

Example 3
Evaluate the concatenation of a text value with an identifier.
Usage

[Link]([Link]("""abc") & " & " & [Link]("x"), [x = "def"""])

Output
"""abcdef"""
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](name as text) as text

About
Returns the M source code representation of an identifier name .

Example 1
Get the M source code representation of an identifier.
Usage

[Link]("MyIdentifier")

Output
"MyIdentifier"

Example 2
Get the M source code representation of an identifier that contains a space.
Usage

[Link]("My Identifier")

Output
"#""My Identifier"""
Function values
9/13/2022 • 2 minutes to read

These functions create and invoke other M functions.

NAME DESC RIP T IO N

[Link] Takes a unary function function and creates a new


function with the type functionType that constructs a list
out of its arguments and passes it to function .

[Link] Invokes the given function using the specified and returns
the result.

[Link] Returns the result of invoking function after duration delay


has passed.

[Link] Returns whether or not function is considered a data source.

[Link] Returns a scalar function of type scalarFunctionType that


invokes vectorFunction with a single row of arguments and
returns its single output.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](functionType as type, function as function) as function

About
Takes a unary function function and creates a new function with the type functionType that constructs a list
out of its arguments and passes it to function .

Example 1
Converts [Link] into a two-argument function whose arguments are added together.
Usage

[Link](type function (a as number, b as number) as number, [Link])(2, 1)

Output
3

Example 2
Converts a function taking a list into a two-argument function.
Usage

[Link](type function (a as text, b as text) as text, (list) => list{0} & list{1})("2", "1")

Output
"21"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function, args as list) as any

About
Invokes the given function using the specified list of arguments and returns the result.

Example 1
Invokes [Link] with one argument [A=1,B=2]
Usage

[Link]([Link], {[A = 1, B = 2]}

Output
{"A", "B"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function, delay as duration) as any

About
Returns the result of invoking function after duration delay has passed.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function) as logical

About
Returns whether or not function is considered a data source.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](scalarFunctionType as type, vectorFunction as function) as function

About
Returns a scalar function of type scalarFunctionType that invokes vectorFunction with a single row of
arguments and returns its single output. Additionally, when the scalar function is repeatedly applied for each
row of a table of inputs, such as in [Link], instead vectorFunction will be applied once for all inputs.
vectorFunction will be passed a table whose columns match in name and position the parameters of
scalarFunctionType . Each row of this table contains the arguments for one call to the scalar function, with the
columns corresponding to the parameters of scalarFunctionType .
vectorFunction must return a list of the same length as the input table, whose item at each position must be the
same result as evaluating the scalar function on the input row of the same position.
The input table is expected to be streamed in, so vectorFunction is expected to stream its output as input comes
in, only working with one chunk of input at a time. In particular, vectorFunction must not enumerate its input
table more than once.
Lines functions
9/13/2022 • 2 minutes to read

These functions convert lists of text to and from binary and single text values.

NAME DESC RIP T IO N

[Link] Converts a binary value to a list of text values split at lines


breaks.

[Link] Converts a text value to a list of text values split at lines


breaks.

[Link] Converts a list of text into a binary value using the specified
encoding and [Link] specified lineSeparator is
appended to each line. If not specified then the carriage
return and line feed characters are used.

[Link] Converts a list of text into a single text. The specified


lineSeparator is appended to each line. If not specified then
the carriage return and line feed characters are used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as binary, optional quoteStyle as nullable number, optional
includeLineSeparators as nullable logical, optional encoding as nullable number) as list

About
Converts a binary value to a list of text values split at lines breaks. If a quote style is specified, then line breaks
may appear within quotes. If includeLineSeparators is true, then the line break characters are included in the
text.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text, optional quoteStyle as nullable number, optional
includeLineSeparators as nullable logical) as list

About
Converts a text value to a list of text values split at lines breaks. If includeLineSeparators is true, then the line
break characters are included in the text.
[Link]: (default) No quoting behavior is needed.
[Link]: Quoting is as per Csv. A double quote character is used to demarcate such regions, and a
pair of double quote characters is used to indicate a single double quote character within such a region.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lines as list, optional lineSeparator as nullable text, optional encoding as
nullable number, optional includeByteOrderMark as nullable logical) as binary

About
Converts a list of text into a binary value using the specified encoding and [Link] specified
lineSeparator is appended to each line. If not specified then the carriage return and line feed characters are used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lines as list, optional lineSeparator as nullable text) as text

About
Converts a list of text into a single text. The specified lineSeparator is appended to each line. If not specified then
the carriage return and line feed characters are used.
List functions
9/13/2022 • 7 minutes to read

These functions create and manipulate list values.

Information
NAME DESC RIP T IO N

[Link] Returns the number of items in a list.

[Link] Returns the number of items in a list excluding null values

[Link] Returns whether a list is empty.

Selection
NAME DESC RIP T IO N

[Link] Returns a list with the items alternated from the original list
based on a count, optional repeatInterval, and an optional
offset.

[Link] Buffers the list in memory. The result of this call is a stable
list, which means it will have a determinimic count, and order
of items.

[Link] Filters a list down by removing duplicates. An optional


equation criteria value can be specified to control equality
comparison. The first value from each equality group is
chosen.

[Link] Searches a list of values, including record fields, for a text


value.

[Link] Returns the first value of the list or the specified default if
empty. Returns the first item in the list, or the optional
default value, if the list is empty. If the list is empty and a
default value is not specified, the function returns.

[Link] Returns the first set of items in the list by specifying how
many items to return or a qualifying condition provided by
countOrCondition .

[Link] Inserts items from values at the given index in the input list.

[Link] Returns whether a list is distinct.

[Link] Returns the last set of items in the list by specifying how
many items to return or a qualifying condition provided by
countOrCondition .
NAME DESC RIP T IO N

[Link] Returns the last set of items in a list by specifying how many
items to return or a qualifying condition.

[Link] Returns true if all items in a list meet a condition.

[Link] Returns true if any item in a list meets a condition.

[Link] Returns a list of positions for an input list.

[Link] Returns a count items starting at an offset.

[Link] Selects the items that match a condition.

[Link] Returns the single item of the list or throws an


[Link] if the list has more than one item.

[Link] Returns a single item from a list.

[Link] Skips the first item of the list. Given an empty list, it returns
an empty list. This function takes an optional parameter
countOrCondition to support skipping multiple values.

Transformation functions
NAME DESC RIP T IO N

[Link] Accumulates a result from the list. Starting from the initial
value seed this function applies the accumulator function
and returns the final result.

[Link] Merges a list of lists into single list.

[Link] This function is intended for internal use only.

[Link] Returns a list that removes count items starting at offset.


The default count is 1.

[Link] Returns a list with the specified number of elements


removed from the list starting at the first element. The
number of elements removed depends on the optional
countOrCondition parameter.

[Link] Removes items from list1 that are present in list2 ,


and returns a new list.
NAME DESC RIP T IO N

[Link] Returns a list with the specified number of elements


removed from the list starting at the last element. The
number of elements removed depends on the optional
countOrCondition parameter.

[Link] Returns a list that repeats the contents of an input list count
times.

[Link] Returns a list that replaces count values in a list with a


replaceWith list starting at an index.

[Link] Removes all occurrences of the given values in the list.

[Link] Removes null values from a list.

[Link] Replaces occurrences of existing values in the list with new


values using the provided equationCriteria . Old and new
values are provided by the replacements parameters. An
optional equation criteria value can be specified to control
equality comparisons. For details of replacement operations
and equation criteria, go to Parameter values.

[Link] Searches a list of values for the value and replaces each
occurrence with the replacement value.

[Link] Returns a list that reverses the items in a list.

[Link] Splits the specified list into a list of lists using the specified
page size.

[Link] Performs the function on each item in the list and returns
the new list.

[Link] Returns a list whose elements are projected from the input
list.

Membership functions
Since all values can be tested for equality, these functions can operate over heterogeneous lists.

NAME DESC RIP T IO N

[Link] Returns true if all expressions in a list are true

[Link] Returns true if any expression in a list in true

[Link] Returns true if a value is found in a list.

[Link] Returns true if all items in values are found in a list.

[Link] Returns true if any item in values is found in a list.


NAME DESC RIP T IO N

[Link] Finds the first occurrence of a value in a list and returns its
position.

[Link] Finds the first occurrence of any value in values and returns
its position.

Set operations
NAME DESC RIP T IO N

[Link] Returns the items in list 1 that do not appear in list 2.


Duplicate values are supported.

[Link] Returns a list from a list of lists and intersects common items
in individual lists. Duplicate values are supported.

[Link] Returns a list from a list of lists and unions the items in the
individual lists. The returned list contains all items in any
input lists. Duplicate values are matched as part of the
Union.

[Link] Returns a list of lists combining items at the same position.

Ordering
Ordering functions perform comparisons. All values that are compared must be comparable with each other.
This means they must all come from the same datatype (or include null, which always compares smallest).
Otherwise, an [Link] is thrown.
Comparable data types include:
Number
Duration
DateTime
Text
Logical
Null

NAME DESC RIP T IO N

[Link] Returns the maximum item in a list, or the optional default


value if the list is empty.

[Link] Returns the maximum values in the list. The number of


values to return or a filtering condition must be specified.

[Link] Returns the median item from a list.

[Link] Returns the minimum item in a list, or the optional default


value if the list is empty.
NAME DESC RIP T IO N

[Link] Returns the minimum values in a list. The number of values


to return or a filtering condition may be specified.

[Link] Returns a sorted list using comparison criterion.

[Link] Returns one or more sample percentiles corresponding to


the given probabilities.

Averages
These functions operate over homogeneous lists of Numbers, DateTimes, and Durations.

NAME DESC RIP T IO N

[Link] Returns an average value from a list in the datatype of the


values in the list.

[Link] Returns an item that appears most commonly in a list.

[Link] Returns all items that appear with the same maximum
frequency.

[Link] Returns the standard deviation from a list of values.


[Link] performs a sample based
estimate. The result is a number for numbers, and a duration
for DateTimes and Durations.

Addition
These functions work over homogeneous lists of Numbers or Durations.

NAME DESC RIP T IO N

[Link] Returns the sum from a list.

Numerics
These functions only work over numbers.

NAME DESC RIP T IO N

[Link] Returns the covariance from two lists as a number.

[Link] Returns the product from a list of numbers.

Generators
These functions generate list of values.
NAME DESC RIP T IO N

[Link] Returns a list of date values from size count, starting at start
and adds an increment to every value.

[Link] Returns a list of datetime values from size count, starting at


start and adds an increment to every value.

[Link] Returns a list of of datetimezone values from size count,


starting at start and adds an increment to every value.

[Link] Returns a list of durations values from size count, starting at


start and adds an increment to every value.

[Link] Generates a list of values.

[Link] Returns a list of numbers from size count starting at initial,


and adds an increment. The increment defaults to 1.

[Link] Returns a list of count random numbers, with an optional


seed parameter.

[Link] Returns a list of time values of size count, starting at start.

Parameter values
Occurrence specification
[Link] = 0;
[Link] = 1;
[Link] = 2;
Sort order
[Link] = 0;
[Link] = 1;
Equation criteria
Equation criteria for list values can be specified as either:
A function value that is either:
A key selector that determines the value in the list to apply the equality criteria.
A comparer function that is used to specify the kind of comparison to apply. Built in comparer
functions can be specified—go to Comparer functions.
A list value that has:
Exactly two items.
The first element is the key selector as specified above.
The second element is a comparer as specified above.
For more information and examples, go to [Link].
Comparison criteria
Comparison criterion can be provided as either of the following values:
A number value to specify a sort order. For more information, go to Sort order.
To compute a key to be used for sorting, a function of one argument can be used.
To both select a key and control order, comparison criterion can be a list containing the key and order.
To completely control the comparison, a function of two arguments can be used that returns -1, 0, or 1 given
the relationship between the left and right inputs. [Link] is a method that can be used to delegate
this logic.
For more information and examples, go to [Link].
Replacement operations
Replacement operations are specified by a list value. Each item of this list must be:
A list value of exactly two items.
First item is the old value in the list, to be replaced.
Second item is the new value, which should replace all occurrences of the old value in the list.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, seed as any, accumulator as function) as any

About
Accumulates a summary value from the items in the list list , using accumulator . An optional seed parameter,
seed , may be set.

Example 1
Accumulates the summary value from the items in the list {1, 2, 3, 4, 5} using ((state, current) => state + current
).
Usage

[Link]({1, 2, 3, 4, 5}, 0, (state, current) => state + current)

Output
15
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as logical

About
Returns true if all expressions in the list list are true.

Example 1
Determine if all the expressions in the list {true, true, 2 > 0} are true.
Usage

[Link]({true, true, 2 > 0})

Output
true

Example 2
Determine if all the expressions in the list {true, true, 2 < 0} are true.
Usage

[Link]({true, false, 2 < 0})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, count as number, optional repeatInterval as nullable number,
optional offset as nullable number) as list

About
Returns a list comprised of all the odd numbered offset elements in a list. Alternates between taking and
skipping values from the list list depending on the parameters.
count : Specifies number of values that are skipped each time.
repeatInterval : An optional repeat interval to indicate how many values are added in between the skipped
values.
offset : An option offset parameter to begin skipping the values at the initial offset.

Example 1
Create a list from {1..10} that skips the first number.
Usage

[Link]({1..10}, 1)

Output
{2, 3, 4, 5, 6, 7, 8, 9, 10}

Example 2
Create a list from {1..10} that skips every other number.
Usage

[Link]({1..10}, 1, 1)

Output
{2, 4, 6, 8, 10}

Example 3
Create a list from {1..10} that starts at 1 and skips every other number.
Usage

[Link]({1..10}, 1, 1, 1)
Output
{1, 3, 5, 7, 9}

Example 4
Create a list from {1..10} that starts at 1, skips one value, keeps two values, and so on.
Usage

[Link]({1..10}, 1, 2, 1)

Output
{1, 3, 4, 6, 7, 9, 10}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as logical

About
Returns true if any expression in the list list is true.

Example 1
Determine if any of the expressions in the list {true, false, 2 > 0} are true.
Usage

[Link]({true, false, 2>0})

Output
true

Example 2
Determine if any of the expressions in the list {2 = 0, false, 2 < 0} are true.
Usage

[Link]({2 = 0, false, 2 < 0})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional precision as nullable number) as any

About
Returns the average value for the items in the list, list . The result is given in the same datatype as the values in
the list. Only works with number, date, time, datetime, datetimezone and duration values. If the list is empty null
is returned.

Example 1
Find the average of the list of numbers, {3, 4, 6} .
Usage

[Link]({3, 4, 6})

Output
4.333333333333333

Example 2
Find the average of the date values January 1, 2011, January 2, 2011 and January 3, 2011.
Usage

[Link]({#date(2011, 1, 1), #date(2011, 1, 2), #date(2011, 1, 3)})

Output
#date(2011, 1, 2)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as list

About
Buffers the list list in memory. The result of this call is a stable list.

Example 1
Create a stable copy of the list {1..10}.
Usage

[Link]({1..10})

Output
{1, 2, 3, 4, 5, 6, 7, 8, 9, 10}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lists as list) as list

About
Takes a list of lists, lists , and merges them into a single new list.

Example 1
Combine the two simple lists {1, 2} and {3, 4}.
Usage

[Link]({{1, 2}, {3, 4}})

Output

{
1,
2,
3,
4
}

Example 2
Combine the two lists, {1, 2} and {3, {4, 5}}, one of which contains a nested list.
Usage

[Link]({{1, 2}, {3, {4, 5}}})

Output

{
1,
2,
3,
{4, 5}
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional options as nullable record) as table

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, value as any, optional equationCriteria as any) as logical

About
Indicates whether the list list contains the value value . Returns true if value is found in the list, false
otherwise. An optional equation criteria value, equationCriteria , can be specified to control equality testing.

Example 1
Find if the list {1, 2, 3, 4, 5} contains 3.
Usage

[Link]({1, 2, 3, 4, 5}, 3)

Output
true

Example 2
Find if the list {1, 2, 3, 4, 5} contains 6.
Usage

[Link]({1, 2, 3, 4, 5}, 6)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, values as list, optional equationCriteria as any) as logical

About
Indicates whether the list list includes all the values in another list, values . Returns true if value is found in
the list, false otherwise. An optional equation criteria value, equationCriteria , can be specified to control
equality testing.

Example 1
Find out if the list {1, 2, 3, 4, 5} contains 3 and 4.
Usage

[Link]({1, 2, 3, 4, 5}, {3, 4})

Output
true

Example 2
Find out if the list {1, 2, 3, 4, 5} contains 5 and 6.
Usage

[Link]({1, 2, 3, 4, 5}, {5, 6})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, values as list, optional equationCriteria as any) as logical

About
Indicates whether the list list includes any of the values in another list, values . Returns true if value is found
in the list, false otherwise. An optional equation criteria value, equationCriteria , can be specified to control
equality testing.

Example 1
Find out if the list {1, 2, 3, 4, 5} contains 3 or 9.
Usage

[Link]({1, 2, 3, 4, 5}, {3, 9})

Output
true

Example 2
Find out if the list {1, 2, 3, 4, 5} contains 6 or 7.
Usage

[Link]({1, 2, 3, 4, 5}, {6, 7})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as number

About
Returns the number of items in the list list .

Example 1
Find the number of values in the list {1, 2, 3}.
Usage

[Link]({1, 2, 3})

Output
3
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](numberList1 as list, numberList2 as list) as nullable number

About
Returns the covariance between two lists, numberList1 and numberList2 . numberList1 and numberList2 must
contain the same number of number values.

Example 1
Calculate the covariance between two lists.
Usage

[Link]({1, 2, 3}, {1, 2, 3})

Output
0.66666666666666607
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](start as date, count as number, step as duration) as list

About
Returns a list of date values of size count , starting at start . The given increment, step , is a duration value
that is added to every value.

Example 1
Create a list of 5 values starting from New Year's Eve (#date(2011, 12, 31)) incrementing by 1 day(#duration(1,
0, 0, 0)).
Usage

[Link](#date(2011, 12, 31), 5, #duration(1, 0, 0, 0))

Output

{
#date(2011, 12, 31),
#date(2012, 1, 1),
#date(2012, 1, 2),
#date(2012, 1, 3),
#date(2012, 1, 4)
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](start as datetime, count as number, step as duration) as list

About
Returns a list of datetime values of size count , starting at start . The given increment, step , is a duration
value that is added to every value.

Example
Create a list of 10 values starting from 5 minutes before New Year's Day (#datetime(2011, 12, 31, 23, 55, 0))
incrementing by 1 minute (#duration(0, 0, 1, 0)).
Usage

[Link](#datetime(2011, 12, 31, 23, 55, 0), 10, #duration(0, 0, 1, 0))

Output

{
#datetime(2011, 12, 31, 23, 55, 0),
#datetime(2011, 12, 31, 23, 56, 0),
#datetime(2011, 12, 31, 23, 57, 0),
#datetime(2011, 12, 31, 23, 58, 0),
#datetime(2011, 12, 31, 23, 59, 0),
#datetime(2012, 1, 1, 0, 0, 0),
#datetime(2012, 1, 1, 0, 1, 0),
#datetime(2012, 1, 1, 0, 2, 0),
#datetime(2012, 1, 1, 0, 3, 0),
#datetime(2012, 1, 1, 0, 4, 0)
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](start as datetimezone, count as number, step as duration) as list

About
Returns a list of datetimezone values of size count , starting at start . The given increment, step , is a
duration value that is added to every value.

Example 1
Create a list of 10 values starting from 5 minutes before New Year's Day (#datetimezone(2011, 12, 31, 23, 55, 0,
-8, 0)) incrementing by 1 minute (#duration(0, 0, 1, 0)).
Usage

[Link](#datetimezone(2011, 12, 31, 23, 55, 0, -8, 0), 10, #duration(0, 0, 1, 0))

Output

{
#datetimezone(2011, 12, 31, 23, 55, 0, -8, 0),
#datetimezone(2011, 12, 31, 23, 56, 0, -8, 0),
#datetimezone(2011, 12, 31, 23, 57, 0, -8, 0),
#datetimezone(2011, 12, 31, 23, 58, 0, -8, 0),
#datetimezone(2011, 12, 31, 23, 59, 0, -8, 0),
#datetimezone(2012, 1, 1, 0, 0, 0, -8, 0),
#datetimezone(2012, 1, 1, 0, 1, 0, -8, 0),
#datetimezone(2012, 1, 1, 0, 2, 0, -8, 0),
#datetimezone(2012, 1, 1, 0, 3, 0, -8, 0),
#datetimezone(2012, 1, 1, 0, 4, 0, -8, 0)
}
[Link]
9/13/2022 • 2 minutes to read

[Link](list1 as list, list2 as list, optional equationCriteria as any) as list

About
Returns the items in list list1 that do not appear in list list2 . Duplicate values are supported. An optional
equation criteria value, equationCriteria , can be specified to control equality testing.

Example 1
Find the items in list {1, 2, 3, 4, 5} that do not appear in {4, 5, 3}.
Usage

[Link]({1, 2, 3, 4, 5}, {4, 5, 3})

Output
{1, 2}

Example 2
Find the items in the list {1, 2} that do not appear in {1, 2, 3}.
Usage

[Link]({1, 2}, {1, 2, 3})

Output
{}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional equationCriteria as any) as list

About
Returns a list that contains all the values in list list with duplicates removed. If the list is empty, the result is an
empty list.

Example 1
Remove the duplicates from the list {1, 1, 2, 3, 3, 3}.
Usage

[Link]({1, 1, 2, 3, 3, 3})

Output
{1, 2, 3}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](start as duration, count as number, step as duration) as list

About
Returns a list of count duration values, starting at start and incremented by the given duration step .

Example 1
Create a list of 5 values starting 1 hour and incrementing by an hour.
Usage

[Link](#duration(0, 1, 0, 0), 5, #duration(0, 1, 0, 0))

Output

{
#duration(0, 1, 0, 0),
#duration(0, 2, 0, 0),
#duration(0, 3, 0, 0),
#duration(0, 4, 0, 0),
#duration(0, 5, 0, 0)
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, text as text) as list

About
Returns a list of the values from the list list which contained the value text .

Example 1
Find the text values in the list {"a", "b", "ab"} that match "a".
Usage

[Link]({"a", "b", "ab"}, "a")

Output
{"a", "ab"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional defaultValue as any) as any

About
Returns the first item in the list list , or the optional default value, defaultValue , if the list is empty. If the list is
empty and a default value is not specified, the function returns null .

Example 1
Find the first value in the list {1, 2, 3}.
Usage

[Link]({1, 2, 3})

Output
1

Example 2
Find the first value in the list {}. If the list is empty, return -1.
Usage

[Link]({}, -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, countOrCondition as any) as any

About
If a number is specified, up to that many items are returned.
If a condition is specified, all items are returned that initially meet the condition. Once an item fails the
condition, no further items are considered.

Example 1
Find the intial values in the list {3, 4, 5, -1, 7, 8, 2} that are greater than 0.
Usage

[Link]({3, 4, 5, -1, 7, 8, 2}, each _ > 0)

Output
{3, 4, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](initial as function, condition as function, next as function, optional selector as
nullable function) as list

About
Generates a list of values using the provided functions. The initial function generates a starting candidate
value, which is then tested against condition . If the candidate value is approved, then it's returned as part of the
resulting list, and the next candidate value is generated by passing the newly approved value to next . Once a
candidate value fails to match condition , the list generation process stops. An optional parameter, selector ,
may also be provided to transform the items in the resulting list.

Example 1
Create a list by starting at ten, repeatedly decrementing by one, and ensuring each item is greater than zero.
Usage

[Link](() => 10, each _ > 0, each _ - 1)

Output
{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}

Example 2
Generate a list of records containing x and y, where x is a value and y is a list. x should remain less than 10 and
represent the number of items in the list y. After the list is generated, return only the x values.
Usage

[Link](
() => [x = 1, y = {}],
each [x] < 10,
each [x = [Link]([y]), y = [y] & {x}],
each [x]
)

Output
{1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, index as number, values as list) as list

About
Returns a new list produced by inserting the values in values into list at index . The first position in the list
is at index 0.
list : The target list where values are to be inserted.
index : The index of the target list( list ) where the values are to be inserted. The first position in the list is at
index 0.
values : The list of values which are to be inserted into list .

Example 1
Insert the list ({3, 4}) into the target list ({1, 2, 5}) at index 2.
Usage

[Link]({1, 2, 5}, 2, {3, 4})

Output

{
1,
2,
3,
4,
5
}

Example 2
Insert a list with a nested list ({1, {1.1, 1.2}}) into a target list ({2, 3, 4}) at index 0.
Usage

[Link]({2, 3, 4}, 0, {1, {1.1, 1.2}})

Output
{
1,
{
1.1,
1.2
},
2,
3,
4
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lists as list, optional equationCriteria as any) as list

About
Returns the intersection of the list values found in the input list lists . An optional parameter, equationCriteria
, can be specified.

Example 1
Find the intersection of the lists {1..5}, {2..6}, {3..7}.
Usage

[Link]({{1..5}, {2..6}, {3..7}})

Output
{3, 4, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional equationCriteria as any) as logical

About
Returns a logical value whether there are duplicates in the list list ; true if the list is distinct, false if there
are duplicate values.

Example 1
Find if the list {1, 2, 3} is distinct (i.e. no duplicates).
Usage

[Link]({1, 2, 3})

Output
true

Example 2
Find if the list {1, 2, 3, 3} is distinct (i.e. no duplicates).
Usage

[Link]({1, 2, 3, 3})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as logical

About
Returns true if the list, list , contains no values (length 0). If the list contains values (length > 0), returns
false .

Example 1
Find if the list {} is empty.
Usage

[Link]({})

Output
true

Example 2
Find if the list {1, 2} is empty.
Usage

[Link]({1, 2})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional defaultValue as any) as any

About
Returns the last item in the list list , or the optional default value, defaultValue , if the list is empty. If the list is
empty and a default value is not specified, the function returns null .

Example 1
Find the last value in the list {1, 2, 3}.
Usage

[Link]({1, 2, 3})

Output
3

Example 2
Find the last value in the list {} or -1 if it empty.
Usage

[Link]({}, -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional countOrCondition as any) as any

About
Returns the last item of the list list . If the list is empty, an exception is thrown. This function takes an optional
parameter, countOrCondition , to support gathering multiple items or filtering items. countOrCondition can be
specified in three ways:
If a number is specified, up to that many items are returned.
If a condition is specified, all items are returned that initially meet the condition, starting at the end of the list.
Once an item fails the condition, no further items are considered.
If this parameter is null the last item in the list is returned.

Example 1
Find the last value in the list {3, 4, 5, -1, 7, 8, 2}.
Usage

[Link]({3, 4, 5, -1, 7, 8, 2}, 1)

Output
{2}

Example 2
Find the last values in the list {3, 4, 5, -1, 7, 8, 2} that are greater than 0.
Usage

[Link]({3, 4, 5, -1, 7, 8, 2}, each _ > 0)

Output
{7, 8, 2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, condition as function) as logical

About
Returns true if the condition function, condition , is satisfied by all values in the list list , otherwise returns
false .

Example 1
Determine if all the values in the list {11, 12, 13} are greater than 10.
Usage

[Link]({11, 12, 13}, each _ > 10)

Output
true

Example 2
Determine if all the values in the list {1, 2, 3} are greater than 10.
Usage

[Link]({1, 2, 3}, each _ > 10)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, condition as function) as logical

About
Returns true if the condition function, condition , is satisfied by any of values in the list list , otherwise
returns false .

Example 1
Find if any of the values in the list {9, 10, 11} are greater than 10.
Usage

[Link]({9, 10, 11}, each _ > 10)

Output
true

Example 2
Find if any of the values in the list {1, 2, 3} are greater than 10.
Usage

[Link]({1, 2, 3}, each _ > 10)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional default as any, optional comparisonCriteria as any, optional
includeNulls as nullable logical) as any

About
Returns the maximum item in the list list , or the optional default value default if the list is empty. An
optional comparisonCriteria value, comparisonCriteria , may be specified to determine how to compare the
items in the list. If this parameter is null, the default comparer is used.

Example 1
Find the max in the list {1, 4, 7, 3, -2, 5}.
Usage

[Link]({1, 4, 7, 3, -2, 5}, 1)

Output
7

Example 2
Find the max in the list {} or return -1 if it is empty.
Usage

[Link]({}, -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, countOrCondition as any, optional comparisonCriteria as any, optional
includeNulls as nullable logical) as list

About
Returns the maximum value(s) in the list, list . After the rows are sorted, optional parameters may be specified
to further filter the result. The optional parameter countOrCondition specifies the number of values to return or
a filtering condition. The optional parameter comparisonCriteria specifies how to compare values in the list.
list : The list of values.
countOrCondition : If a number is specified, a list of up to countOrCondition items in ascending order is
returned. If a condition is specified, a list of items that initially meet the condition is returned. Once an item
fails the condition, no further items are considered.
comparisonCriteria : [Optional] An optional comparisonCriteria value can be specified to determine how to
compare the items in the list. If this parameter is null, the default comparer is used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional comparisonCriteria as any) as any

About
Returns the median item of the list list . This function returns null if the list contains no non- null values. If
there is an even number of items, the function chooses the smaller of the two median items unless the list is
comprised entirely of datetimes, durations, numbers or times, in which case it returns the average of the two
items.

Example 1
Find the median of the list {5, 3, 1, 7, 9} .
Usage

[Link]({5, 3, 1, 7, 9})

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional default as any, optional comparisonCriteria as any, optional
includeNulls as nullable logical) as any

About
Returns the minimum item in the list list , or the optional default value default if the list is empty. An
optional comparisonCriteria value, comparisonCriteria , may be specified to determine how to compare the
items in the list. If this parameter is null, the default comparer is used.

Example 1
Find the min in the list {1, 4, 7, 3, -2, 5}.
Usage

[Link]({1, 4, 7, 3, -2, 5})

Output
-2

Example 2
Find the min in the list {} or return -1 if it is empty.
Usage

[Link]({}, -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, countOrCondition as any, optional comparisonCriteria as any, optional
includeNulls as nullable logical) as list

About
Returns the minimum value(s) in the list, list . The parameter, countOrCondition , specifies the number of
values to return or a filtering condition. The optional parameter, comparisonCriteria , specifies how to compare
values in the list.
list : The list of values.
countOrCondition : If a number is specified, a list of up to countOrCondition items in ascending order is
returned. If a condition is specified, a list of items that initially meet the condition is returned. Once an item
fails the condition, no further items are considered. If this parameter is null, the single smallest value in the
list is returned.
comparisonCriteria : [Optional] An optional comparisonCriteria value can be specified to determine how to
compare the items in the list. If this parameter is null, the default comparer is used.

Example 1
Find the 5 smallest values in the list {3, 4, 5, -1, 7, 8, 2} .
Usage

[Link]({3, 4, 5, -1, 7, 8, 2}, 5)

Output
{-1, 2, 3, 4, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional equationCriteria as any) as any

About
Returns the item that appears most frequently in list . If the list is empty an exception is thrown. If multiple
items appear with the same maximum frequency, the last one is chosen. An optional comparison criteria value,
equationCriteria , can be specified to control equality testing.

Example 1
Find the item that appears most frequently in the list {"A", 1, 2, 3, 3, 4, 5} .
Usage

[Link]({"A", 1, 2, 3, 3, 4, 5})

Output
3

Example 2
Find the item that appears most frequently in the list {"A", 1, 2, 3, 3, 4, 5, 5} .
Usage

[Link]({"A", 1, 2, 3, 3, 4, 5, 5})

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional equationCriteria as any) as list

About
Returns the items that appear most frequently in list . If the list is empty an exception is thrown. If multiple
items appear with the same maximum frequency, all of them are returned. An optional comparison criteria
value, equationCriteria , can be specified to control equality testing.

Example 1
Find the items that appears most frequently in the list {"A", 1, 2, 3, 3, 4, 5, 5} .
Usage

[Link]({"A", 1, 2, 3, 3, 4, 5, 5})

Output
{3, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as number

About
Returns the number of non-null items in the list list .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](start as number, count as number, optional increment as nullable number) as list

About
Returns a list of numbers given an initial value, count, and optional increment value. The default increment value
is 1.
start : The initial value in the list.
count : The number of values to create.
`increment: [Optional] The value to increment by. If omitted values are incremented by 1.

Example 1
Generate a list of 10 consecutive numbers starting at 1.
Usage

[Link](1, 10)

Output

{
1,
2,
3,
4,
5,
6,
7,
8,
9,
10
}

Example 2
Generate a list of 10 numbers starting at 1, with an increment of 2 for each subsequent number.
Usage

[Link](1, 10, 2)

Output
{
1,
3,
5,
7,
9,
11,
13,
15,
17,
19
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, percentiles as any, optional options as nullable record) as any

About
Returns one or more sample percentiles of the list list . If the value percentiles is a number between 0.0 and
1.0, it will be treated as a percentile and the result will be a single value corresponding to that probability. If the
value percentiles is a list of numbers with values between 0.0 and 1.0, the result will be a list of percentiles
corresponding to the input probability.
The PercentileMode option in options can be used by advanced users to pick a more-specific interpolation
method but is not recommended for most uses. Predefined symbols [Link] and
[Link] match the interpolation methods used by the Excel functions [Link] and
[Link] . The default behavior matches [Link] . The symbols [Link]
and [Link] match the SQL Server behavior for PERCENTILE_CONT and PERCENTILE_DISC ,
respectively.

Example 1
Find the first quartile of the list {5, 3, 1, 7, 9} .
Usage

[Link]({5, 3, 1, 7, 9}, 0.25)

Output
3

Example 2
Find the quartiles of the list {5, 3, 1, 7, 9} using an interpolation method matching Excel's [Link] .
Usage

[Link]({5, 3, 1, 7, 9}, {0.25, 0.5, 0.75}, [PercentileMode=[Link]])

Output
{2, 5, 8}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, value as any, optional occurrence as nullable number, optional
equationCriteria as any) as any

About
Returns the offset at which the value value appears in the list list . Returns -1 if the value doesn't appear. An
optional occurrence parameter occurrence can be specified.
occurrence : The maximum number of occurrences to report.

Example 1
Find the position in the list {1, 2, 3} at which the value 3 appears.
Usage

[Link]({1, 2, 3}, 3)

Output
2
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, values as list, optional occurrence as nullable number,
optional equationCriteria as any) as any

About
Returns the offset in list list of the first occurrence of a value in a list values . Returns -1 if no occurrence is
found. An optional occurrence parameter occurrence can be specified.
occurrence : The maximum number of occurrences that can be returned.

Example 1
Find the first position in the list {1, 2, 3} at which the value 2 or 3 appears.
Usage

[Link]({1, 2, 3}, {2, 3})

Output
1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as list

About
Returns a list of offsets for the input list list . When using [Link] to change a list, the list of positions
can be used to give the transform access to the position.

Example 1
Find the offsets of values in the list {1, 2, 3, 4, null, 5}.
Usage

[Link]({1, 2, 3, 4, null, 5})

Output
{0, 1, 2, 3, 4, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](numbersList as list, optional precision as nullable number) as nullable number

About
Returns the product of the non-null numbers in the list, numbersList . Returns null if there are no non-null values
in the list.

Example 1
Find the product of the numbers in the list {1, 2, 3, 3, 4, 5, 5} .
Usage

[Link]({1, 2, 3, 3, 4, 5, 5})

Output
1800
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](count as number, optional seed as nullable number) as list

About
Returns a list of random numbers between 0 and 1, given the number of values to generate and an optional
seed value.
count : The number of random values to generate.
seed : [Optional] A numeric value used to seed the random number generator. If omitted a unique list of
random numbers is generated each time you call the function. If you specify the seed value with a number
every call to the function generates the same list of random numbers.

Example 1
Create a list of 3 random numbers.
Usage

[Link](3)

Output
{0.992332, 0.132334, 0.023592}

Example 2
Create a list of 3 random numbers, specifying seed value.
Usage

[Link](3, 2)

Output
{0.883002, 0.245344, 0.723212}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, offset as number, optional count as nullable number) as list

About
Returns a subset of the list beginning at the offset list . An optional parameter, offset , sets the maximum
number of items in the subset.

Example 1
Find the subset starting at offset 6 of the list of numbers 1 through 10.
Usage

[Link]({1..10}, 6)

Output
{7, 8, 9, 10}

Example 2
Find the subset of length 2 from offset 6, from the list of numbers 1 through 10.
Usage

[Link]({1..10}, 6, 2)

Output
{7, 8}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional countOrCondition as any) as list

About
Returns a list that removes the first element of list list . If list is an empty list an empty list is returned. This
function takes an optional parameter, countOrCondition , to support removing multiple values as listed below.
If a number is specified, up to that many items are removed.
If a condition is specified, the returned list begins with the first element in list that meets the criteria. Once
an item fails the condition, no further items are considered.
If this parameter is null, the default behavior is observed.

Example 1
Create a list from {1, 2, 3, 4, 5} without the first 3 numbers.
Usage

[Link]({1, 2, 3, 4, 5}, 3)

Output
{4, 5}

Example 2
Create a list from {5, 4, 2, 6, 1} that starts with a number less than 3.
Usage

[Link]({5, 4, 2, 6, 1}, each _ > 3)

Output
{2, 6, 1}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list1 as list, list2 as list) as list

About
Removes all occurrences of the given values in the list2 from list1 . If the values in list2 don't exist in
list1 , the original list is returned.

Example 1
Remove the items in the list {2, 4, 6} from the list {1, 2, 3, 4, 2, 5, 5}.
Usage

[Link]({1, 2, 3, 4, 2, 5, 5}, {2, 4, 6})

Output
{1, 3, 5, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional countOrCondition as any) as list

About
Returns a list that removes the last countOrCondition elements from the end of list list . If list has less than
countOrCondition elements, an empty list is returned.

If a number is specified, up to that many items are removed.


If a condition is specified, the returned list ends with the first element from the bottom in list that meets
the criteria. Once an item fails the condition, no further items are considered.
If this parameter is null, only one item is removed.

Example 1
Create a list from {1, 2, 3, 4, 5} without the last 3 numbers.
Usage

[Link]({1, 2, 3, 4, 5}, 3)

Output
{1, 2}

Example 2
Create a list from {5, 4, 2, 6, 4} that ends with a number less than 3.
Usage

[Link]({5, 4, 2, 6, 4}, each _ > 3)

Output
{5, 4, 2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list1 as list, list2 as list, optional equationCriteria as any) as list

About
Removes all occurrences of the given values in list2 from the list list1 . If the values in list2 don't exist in
list1 , the original list is returned. An optional equation criteria value, equationCriteria , can be specified to
control equality testing.

Example 1
Create a list from {1, 2, 3, 4, 5, 5} without {1, 5}.
Usage

[Link]({1, 2, 3, 4, 5, 5}, {1, 5})

Output
{2, 3, 4}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as list

About
Removes all occurrences of "null" values in the list . If there are no 'null' values in the list, the original list is
returned.

Example 1
Remove the "null" values from the list {1, 2, 3, null, 4, 5, null, 6}.
Usage

[Link]({1, 2, 3, null, 4, 5, null, 6})

Output
{1, 2, 3, 4, 5, 6}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, index as number, optional count as nullable number) as list

About
Removes count values in the list starting at the specified position, index .

Example 1
Remove 3 values in the list {1, 2, 3, 4, -6, -2, -1, 5} starting at index 4.
Usage

[Link]({1, 2, 3, 4, -6, -2, -1, 5}, 4, 3)

Output
{1, 2, 3, 4, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, count as number) as list

About
Returns a list that is count repetitions of the original list, list .

Example 1
Create a list that has {1, 2} repeated 3 times.
Usage

[Link]({1, 2}, 3)

Output
{1, 2, 1, 2, 1, 2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, replacements as list, optional equationCriteria as any)
as list

About
Performs the given replacements to the list list . A replacement operation replacements consists of a list of
two values, the old value and new value, provided in a list. An optional equation criteria value, equationCriteria ,
can be specified to control equality testing.

Example 1
Create a list from {1, 2, 3, 4, 5} replacing the value 5 with -5, and the value 1 with -1.
Usage

[Link]({1, 2, 3, 4, 5}, {{5, -5}, {1, -1}})

Output
{-1, 2, 3, 4, -5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, index as number, count as number, replaceWith as list) as list

About
Replaces count values in the list with the list replaceWith , starting at specified position, index .

Example 1
Replace {7, 8, 9} in the list {1, 2, 7, 8, 9, 5} with {3, 4}.
Usage

[Link]({1, 2, 7, 8, 9, 5}, 2, 3, {3, 4})

Output
{1, 2, 3, 4, 5}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, oldValue as any, newValue as any, replacer as function) as list

About
Searches a list of values, list , for the value oldValue and replaces each occurrence with the replacement value
newValue .

Example 1
Replace all the "a" values in the list {"a", "B", "a", "a"} with "A".
Usage

[Link]({"a", "B", "a", "a"}, "a", "A", [Link])

Output
{"A", "B", "A", "A"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as list

About
Returns a list with the values in the list list in reversed order.

Example 1
Create a list from {1..10} in reverse order.
Usage

[Link]({1..10})

Output
{10, 9, 8, 7, 6, 5, 4, 3, 2, 1}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, selection as function) as list

About
Returns a list of values from the list list , that match the selection condition selection .

Example 1
Find the values in the list {1, -3, 4, 9, -2} that are greater than 0.
Usage

[Link]({1, -3, 4, 9, -2}, each _ > 0)

Output
{1, 4, 9}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list) as any

About
If there is only one item in the list list , returns that item. If there is more than one item or the list is empty, the
function throws an exception.

Example 1
Find the single value in the list {1}.
Usage

[Link]({1})

Output
1

Example 2
Find the single value in the list {1, 2, 3}.
Usage

[Link]({1, 2, 3})

Output
[[Link]] There were too many elements in the enumeration to complete the operation.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional default as any) as any

About
If there is only one item in the list list , returns that item. If the list is empty, the function returns null unless an
optional default is specified. If there is more than one item in the list, the function returns an error.

Example 1
Find the single value in the list {1}.
Usage

[Link]({1})

Output
1

Example 2
Find the single value in the list {}.
Usage

[Link]({})

Output
null

Example 3
Find the single value in the list {}. If is empty, return -1.
Usage

[Link]({}, -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional countOrCondition as any) as list

About
Returns a list that skips the first element of list list . If list is an empty list an empty list is returned. This
function takes an optional parameter, countOrCondition , to support skipping multiple values as listed below.
If a number is specified, up to that many items are skipped.
If a condition is specified, the returned list begins with the first element in list that meets the criteria. Once
an item fails the condition, no further items are considered.
If this parameter is null, the default behavior is observed.

Example 1
Create a list from {1, 2, 3, 4, 5} without the first 3 numbers.
Usage

[Link]({1, 2, 3, 4, 5}, 3)

Output
{4, 5}

Example 2
Create a list from {5, 4, 2, 6, 1} that starts with a number less than 3.
Usage

[Link]({5, 4, 2, 6, 1}, each _ > 3)

Output
{2, 6, 1}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional comparisonCriteria as any) as list

About
Sorts a list of data, list , according to the optional criteria specified. An optional parameter, comparisonCriteria
, can be specified as the comparison criterion. This can take the following values:
To control the order, the comparison criterion can be an Order enum value. ( [Link] ,
[Link] ).

To compute a key to be used for sorting, a function of 1 argument can be used.


To both select a key and control order, comparison criterion can be a list containing the key and order (
{each 1 / _, [Link]} ).

To completely control the comparison, a function of 2 arguments can be used. This function will be
passed two items from the list (any two items, in any order). The function should return one of the
following values:
-1 : The first item is less than the second item.
0 : The items are equal.
1 : The first item is greater than the second item.

[Link] is a method that can be used to delegate this logic.

Example 1
Sort the list {2, 3, 1}.
Usage

[Link]({2, 3, 1})

Output
{1, 2, 3}

Example 2
Sort the list {2, 3, 1} in descending order.
Usage

[Link]({2, 3, 1}, [Link])

Output
{3, 2, 1}

Example 3
Sort the list {2, 3, 1} in descending order using the [Link] method.
Usage

[Link]({2, 3, 1}, (x, y) => [Link](1/x, 1/y))

Output
{3, 2, 1}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, pageSize as number) as list

About
Splits list into a list of lists where the first element of the output list is a list containing the first pageSize
elements from the source list, the next element of the output list is a list containing the next pageSize elements
from the source list, and so on.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](numbersList as list) as nullable number

About
Returns a sample based estimate of the standard deviation of the values in the list, numbersList . If numbersList
is a list of numbers, a number is returned. An exception is thrown on an empty list or a list of items that is not
type number .

Example 1
Find the standard deviation of the numbers 1 through 5.
Usage

[Link]({1..5})

Outut
1.5811388300841898
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional precision as nullable number) as any

About
Returns the sum of the non-null values in the list, list . Returns null if there are no non-null values in the list.

Example 1
Find the sum of the numbers in the list {1, 2, 3} .
Usage

[Link]({1, 2, 3})

Output
6
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](start as time, count as number, step as duration) as list

About
Returns a list of time values of size count , starting at start . The given increment, step , is a duration value
that is added to every value.

Example 1
Create a list of 4 values starting from noon (#time(12, 0, 0)) incrementing by one hour (#duration(0, 1, 0, 0)).
Usage

[Link](#time(12, 0, 0), 4, #duration(0, 1, 0, 0))

Output

{
#time(12, 0, 0),
#time(13, 0, 0),
#time(14, 0, 0),
#time(15, 0, 0)
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, transform as function) as list

About
Returns a new list of values by applying the transform function transform to the list, list .

Example 1
Add 1 to each value in the list {1, 2}.
Usage

[Link]({1, 2}, each _ + 1)

Output
{2, 3}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, collectionTransform as function, resultTransform as function)
as list

About
Returns a list whose elements are projected from the input list. The collectionTransform function is applied to
each element, and the resultTransform function is invoked to construct the resulting list. The
collectionTransform has the signature (x as any) as list => ... where x is an element in list . The
resultTransform projects the shape of the result and has the signature (x as any, y as any) as any => ...
where x is the element in list and y is the element obtained by applying the collectionTransform to that
element.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lists as list, optional equationCriteria as any) as list

About
Takes a list of lists lists , unions the items in the individual lists and returns them in the output list. As a result,
the returned list contains all items in any input lists. This operation maintains traditional bag semantics, so
duplicate values are matched as part of the Union. An optional equation criteria value, equationCriteria , can be
specified to control equality testing.

Example 1
Create a union of the list {1..5}, {2..6}, {3..7}.
Usage

[Link]({{1..5}, {2..6}, {3..7}})

Output
{1, 2, 3, 4, 5, 6, 7}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lists as list) as list

About
Takes a list of lists, lists , and returns a list of lists combining items at the same position.

Example 1
Zips the two simple lists {1, 2} and {3, 4}.
Usage

[Link]({{1, 2}, {3, 4}})

Output

{
{1, 3},
{2, 4}
}

Example 2
Zips the two simple lists of different lengths {1, 2} and {3}.
Usage

[Link]({{1, 2}, {3}})

Output

{
{1, 3},
{2, null}
}
Logical functions
9/13/2022 • 2 minutes to read

These functions create and manipulate logical (that is, true/false) values.

NAME DESC RIP T IO N

[Link] Returns a logical value from a value.

[Link] Returns a logical value of true or false from a text value.

[Link] Returns a text value from a logical value.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as nullable logical

About
Returns a logical value from the given value . If the given value is null , [Link] returns null . If the
given value is logical , value is returned.
Values of the following types can be converted to a logical value:
text :A logical value from the text value, either "true" or "false" . Refer to [Link] for details.
number : false if value equals 0 , true otherwise.
If value is of any other type, an error is returned.

Example 1
Convert 2 to a logical value.
Usage

[Link](2)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text) as nullable logical

About
Creates a logical value from the text value text , either "true" or "false". If text contains a different string, an
exception is thrown. The text value text is case insensitive.

Example 1
Create a logical value from the text string "true".
Usage

[Link]("true")

Output
true

Example 2
Create a logical value from the text string "a".
Usage

[Link]("a")

Output
[[Link]] Could not convert to a logical.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](logicalValue as nullable logical) as nullable text

About
Creates a text value from the logical value logicalValue , either true or false . If logicalValue is not a logical
value, an exception is thrown.

Example 1
Create a text value from the logical true .
Usage

[Link](true)

Output
"true"
Number functions
9/13/2022 • 2 minutes to read

These functions create and manipulate number values.

Information
NAME DESC RIP T IO N

[Link] Returns true if a value is an even number.

[Link] Returns true if a value is [Link].

[Link] Returns true if a value is an odd number.

Conversion and formatting


NAME DESC RIP T IO N

[Link] Returns an 8-bit integer number value from the given value.

[Link] Returns a currency value from the given value.

[Link] Returns a decimal number value from the given value.

[Link] Returns a Double number value from the given value.

[Link] Returns a signed 8-bit integer number value from the given
value.

[Link] Returns a 16-bit integer number value from the given value.

[Link] Returns a 32-bit integer number value from the given value.

[Link] Returns a 64-bit integer number value from the given value.

[Link] Returns a number value from a value.

[Link] Returns a number value from a text value.

[Link] Returns a text value from a number value.

[Link] Returns a percentage value from the given value.

[Link] Returns a Single number value from the given value.

Rounding
NAME DESC RIP T IO N

[Link] Returns a nullable number (n) if value is an integer.

[Link] Returns [Link](value) when value >= 0 and


[Link](value) when value < 0.

[Link] Returns the largest integer less than or equal to a number


value.

[Link] Returns [Link](x) when x >= 0 and


[Link](x) when x < 0.

[Link] Returns the larger integer greater than or equal to a number


value.

Operations
NAME DESC RIP T IO N

[Link] Returns the absolute value of a number.

[Link] Returns the number of combinations of a given number of


items for the optional combination size.

[Link] Returns a number representing e raised to a power.

[Link] Returns the factorial of a number.

[Link] Divides two numbers and returns the whole part of the
resulting number.

[Link] Returns the natural logarithm of a number.

[Link] Returns the logarithm of a number to the base.

Number.Log10 Returns the base-10 logarithm of a number.

[Link] Divides two numbers and returns the remainder of the


resulting number.

[Link] Returns the number of total permutations of a given number


of items for the optional permutation size.

[Link] Returns a number raised by a power.

[Link] Returns 1 for positive numbers, -1 for negative numbers or


0 for zero.

[Link] Returns the square root of a number.

Random
NAME DESC RIP T IO N

[Link] Returns a random fractional number between 0 and 1.

[Link] Returns a random number between the two given number


values.

Trigonometry
NAME DESC RIP T IO N

[Link] Returns the arccosine of a number.

[Link] Returns the arcsine of a number.

[Link] Returns the arctangent of a number.

Number.Atan2 Returns the arctangent of the division of two numbers.

[Link] Returns the cosine of a number.

[Link] Returns the hyperbolic cosine of a number.

[Link] Returns the sine of a number.

[Link] Returns the hyperbolic sine of a number.

[Link] Returns the tangent of a number.

[Link] Returns the hyperbolic tangent of a number.

Bytes
NAME DESC RIP T IO N

[Link] Returns the result of a bitwise AND operation on the


provided operands.

[Link] Returns the result of a bitwise NOT operation on the


provided operands.

[Link] Returns the result of a bitwise OR operation on the provided


operands.

[Link] Returns the result of a bitwise shift left operation on the


operands.

[Link] Returns the result of a bitwise shift right operation on the


operands.

[Link] Returns the result of a bitwise XOR operation on the


provided operands.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text, optional roundingMode as nullable
number) as nullable number

About
Returns an 8-bit integer number value from the given value . If the given value is null , [Link] returns
null . If the given value is a number within the range of an 8-bit integer without a fractional part, value is
returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default
rounding mode is [Link]. If value is of any other type, it will first be converted to a number
using [Link]. Refer to [Link] for the available rounding modes. An optional culture may
also be provided (for example, "en-US").

Example 1
Get the 8-bit integer number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the 8-bit integer number value of "4.5" using [Link].
Usage

[Link]("4.5", null, [Link])

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text, optional roundingMode as nullable
number) as nullable number

About
Returns a currency value from the given value . If the given value is null , [Link] returns null . If
the given value is number within the range of currency, fractional part of the value is rounded to 4 decimal
digits and returned. If value is of any other type, it will first be converted to a number using [Link].
Valid range for currency is -922,337,203,685,477.5808 to 922,337,203,685,477.5807 . Refer to [Link] for
the available rounding modes. The default is [Link]. An optional culture may also be provided
(for example, "en-US").

Example 1
Get the currency value of "1.23455" .
Usage

[Link]("1.23455")

Output
1.2346

Example 2
Get the currency value of "1.23455" using [Link] .
Usage

[Link]("1.23455", "en-US", [Link])

Output
1.2345
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable number

About
Returns a Decimal number value from the given value . If the given value is null , [Link] returns
null . If the given value is number within the range of Decimal, value is returned, otherwise an error is
returned. If value is of any other type, it will first be converted to a number using [Link]. An
optional culture may also be provided (for example, "en-US").

Example 1
Get the Decimal number value of "4.5" .
Usage

[Link]("4.5")

Output
4.5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable number

About
Returns a Double number value from the given value . If the given value is null , [Link] returns null
. If the given value is number within the range of Double, value is returned, otherwise an error is returned. If
value is of any other type, it will first be converted to a number using [Link]. An optional culture
may also be provided (for example, "en-US").

Example 1
Get the Double number value of "4" .
Usage

[Link]("4.5")

Output
4.5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text, optional roundingMode as nullable
number) as nullable number

About
Returns a signed 8-bit integer number value from the given value . If the given value is null , [Link]
returns null . If the given value is number within the range of signed 8-bit integer without a fractional part,
value is returned. If it has fractional part, then the number is rounded with the rounding mode specified. The
default rounding mode is [Link]. If value is of any other type, it will first be converted to a
number using [Link]. Refer to [Link] for the available rounding modes. An optional
culture may also be provided (for example, "en-US").

Example 1
Get the signed 8-bit integer number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the signed 8-bit integer number value of "4.5" using [Link].
Usage

[Link]("4.5", null, [Link])

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text, optional roundingMode as nullable
number) as nullable number

About
Returns a 16-bit integer number value from the given value . If the given value is null , [Link] returns
null . If the given value is number within the range of 16-bit integer without a fractional part, value is
returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default
rounding mode is [Link]. If value is of any other type, it will first be converted to a number
using [Link]. Refer to [Link] for the available rounding modes. An optional culture may
also be provided (for example, "en-US").

Example 1
Get the 16-bit integer number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the 16-bit integer number value of "4.5" using [Link] .
Usage

[Link]("4.5", null, [Link])

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text, optional roundingMode as nullable
number) as nullable number

About
Returns a 32-bit integer number value from the given value . If the given value is null , [Link] returns
null . If the given value is number within the range of 32-bit integer without a fractional part, value is
returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default
rounding mode is [Link]. If value is of any other type, it will first be converted to a number
using [Link]. Refer to [Link] for the available rounding modes. An optional culture may
also be provided (for example, "en-US").

Example 1
Get the 32-bit integer number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the 32-bit integer number value of "4.5" using [Link] .
Usage

[Link]("4.5", null, [Link])

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text, optional roundingMode as nullable
number) as nullable number

About
Returns a 64-bit integer number value from the given value . If the given value is null , [Link] returns
null . If the given value is number within the range of 64-bit integer without a fractional part, value is
returned. If it has fractional part, then the number is rounded with the rounding mode specified. The default
rounding mode is [Link]. If value is of any other type, it will first be converted to a number
using [Link]. Refer to [Link] for the available rounding modes. An optional culture may
also be provided (for example, "en-US").

Example 1
Get the 64-bit integer number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the 64-bit integer number value of "4.5" using [Link] .
Usage

[Link]("4.5", null, [Link])

Output
5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the absolute value of number . If number is null, [Link] returns null.
number :A number for which the absolute value is to be calculated.

Example 1
Absolute value of -3.
Usage

[Link](-3)

Output
3
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the arccosine of number .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the arcsine of number .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the arctangent of number .
Number.Atan2
9/13/2022 • 2 minutes to read

Syntax
Number.Atan2(y as nullable number, x as nullable number) as nullable number

About
Returns the angle, in radians, whose tangent is the quotient y / x of the two numbers y and x .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number1 as nullable number, number2 as nullable number) as nullable number

About
Returns the result of performing a bitwise "And" operation between number1 and number2 .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as any) as any

About
Returns the result of performing a bitwise "Not" operation on number .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number1 as nullable number, number2 as nullable number) as nullable number

About
Returns the result of performing a bitwise "Or" between number1 and number2 .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number1 as nullable number, number2 as nullable number) as nullable
number

About
Returns the result of performing a bitwise shift to the left on number1 , by the specified number of bits number2 .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number1 as nullable number, number2 as nullable number) as nullable
number

About
Returns the result of performing a bitwise shift to the right on number1 , by the specified number of bits
number2 .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number1 as nullable number, number2 as nullable number) as nullable number

About
Returns the result of performing a bitwise "XOR" (Exclusive-OR) between number1 and number2 .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](setSize as nullable number, combinationSize as nullable number) as nullable
number

About
Returns the number of unique combinations from a list of items, setSize with specified combination size,
combinationSize .

setSize : The number of items in the list.


combinationSize : The number of items in each combination.

Example 1
Find the number of combinations from a total of 5 items when each combination is a group of 3.
Usage

[Link](5, 3)

Output
10
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the cosine of number .

Example 1
Find the cosine of the angle 0.
Usage

[Link](0)

Output
1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the hyperbolic cosine of number .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the result of raising e to the power of number (exponential function).
number : A number for which the exponential function is to be calculated. If number is null, [Link]
returns null.

Example 1
Raise e to the power of 3.
Usage

[Link](3)

Output
20.085536923187668
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the factorial of the number number .

Example 1
Find the factorial of 10.
Usage

[Link](10)

Output
3628800
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable number

About
Returns a number value from the given value . An optional culture may also be provided (for example, "en-
US"). If the given value is null , [Link] returns null . If the given value is number , value is
returned. Values of the following types can be converted to a number value:
text : A number value from textual representation. Common text formats are handled ("15", "3,423.10",
"5.0E-10"). Refer to [Link] for details.
logical : 1 for true , 0 for false .
datetime : A double-precision floating-point number that contains an OLE Automation date equivalent.
datetimezone : A double-precision floating-point number that contains an OLE Automation date equivalent of
the local date and time of value .
date : A double-precision floating-point number that contains an OLE Automation date equivalent.
time : Expressed in fractional days.
duration : Expressed in whole and fractional days.

If value is of any other type, an error is returned.

Example 1
Get the number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the number value of #datetime(2020, 3, 20, 6, 0, 0) .
Usage

[Link](#datetime(2020, 3, 20, 6, 0, 0))

Output
43910.25
Example 3
Get the number value of "12.3%" .
Usage

[Link]("12.3%")

Output
0.123
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional culture as nullable text) as nullable number

About
Returns a number value from the given text value, text .
text : The textual representation of a number value. The representation must be in a common number
format, such as "15", "3,423.10", or "5.0E-10".
culture : An optional culture that controls how text is interpreted (for example, "en-US").

Example 1
Get the number value of "4" .
Usage

[Link]("4")

Output
4

Example 2
Get the number value of "5.0e-10" .
Usage

[Link]("5.0e-10")

Output
5E-10
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number1 as nullable number, number2 as nullable number, optional precision
as nullable number) as nullable number

About
Returns the integer portion of the result from dividing a number, number1 , by another number, number2 . If
number1 or number2 are null, [Link] returns null.

number1 : The dividend.


number2 : The divisor.

Example 1
Divide 6 by 4.
Usage

[Link](6, 4)

Output
1

Example 2
Divide 8.3 by 3.
Usage

[Link](8.3, 3)

Output
2
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as number) as logical

About
Indicates if the value, number , is even by returning true if it is even, false otherwise.

Example 1
Check if 625 is an even number.
Usage

[Link](625)

Output
false

Example 2
Check if 82 is an even number.
Usage

[Link](82)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as number) as logical

About
Indicates if the value is NaN (Not a number). Returns true if number is equivalent to [Link] , false
otherwise.

Example 1
Check if 0 divided by 0 is NaN.
Usage

[Link](0/0)

Output
true

Example 2
Check if 1 divided by 0 is NaN.
Usage

[Link](1/0)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as number) as logical

About
Indicates if the value is odd. Returns true if number is an odd number, false otherwise.

Example 1
Check if 625 is an odd number.
Usage

[Link](625)

Output
true

Example 2
Check if 82 is an odd number.
Usage

[Link](82)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the natural logarithm of a number, number . If number is null [Link] returns null.

Example 1
Get the natural logarithm of 15.
Usage

[Link](15)

Output
2.70805020110221
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional base as nullable number) as nullable number

About
Returns the logarithm of a number, number , to the specified base base. If base is not specified, the default
value is Number.E. If number is null [Link] returns null.

Example 1
Get the base 10 logarithm of 2.
Usage

[Link](2, 10)

Output
0.3010299956639812

Example 2
Get the base e logarithm of 2.
Usage

[Link](2)

Output
0.69314718055994529
Number.Log10
9/13/2022 • 2 minutes to read

Syntax
Number.Log10(number as nullable number) as nullable number

About
Returns the base 10 logarithm of a number, number . If number is null Number.Log10 returns null.

Example 1
Get the base 10 logarithm of 2.
Usage

Number.Log10(2)

Output
0.3010299956639812
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, divisor as nullable number, optional precision as nullable
number) as nullable number

About
Returns the remainder resulting from the integer division of number by divisor . If number or divisor are null,
[Link] returns null.

number : The dividend.


divisor : The divisor.

Example 1
Find the remainder when you divide 5 by 3.
Usage

[Link](5, 3)

Output
2
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](setSize as nullable number, permutationSize as nullable number) as nullable
number

About
Returns the number of permutations that can be generated from a number of items, setSize , with a specified
permutation size, permutationSize .

Example 1
Find the number of permutations from a total of 5 items in groups of 3.
Usage

[Link](5, 3)

Output
60
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, power as nullable number) as nullable number

About
Returns the result of raising number to the power of power . If number or power are null, [Link]
returns null.
number : The base.
power : The exponent.

Example 1
Find the value of 5 raised to the power of 3 (5 cubed).
Usage

[Link](5, 3)

Output
125
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as number

About
Returns a random number between 0 and 1.

Example 1
Get a random number.
Usage

[Link]()

Output
0.919303
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](bottom as number, top as number) as number

About
Returns a random number between bottom and top .

Example 1
Get a random number between 1 and 5.
Usage

[Link](1, 5)

Output
2.546797
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional digits as nullable number, optional
roundingMode as nullable number) as nullable number

About
Returns the result of rounding number to the nearest number. If number is null, [Link] returns null.
By default, number is rounded to the nearest integer, and ties are broken by rounding to the nearest even
number (using [Link], also known as "banker's rounding").
However, these defaults can be overridden via the following optional parameters.
digits : Causes number to be rounded to the specified number of decimal digits.
roundingMode : Overrides the default tie-breaking behavior when number is at the midpoint between two
potential rounded values (refer to [Link] for possible values).

Example 1
Round 1.234 to the nearest integer.
Usage

[Link](1.234)

Output
1

Example 2
Round 1.56 to the nearest integer.
Usage

[Link](1.56)

Output
2

Example 3
Round 1.2345 to two decimal places.
Usage
[Link](1.2345, 2)

Output
1.23

Example 4
Round 1.2345 to three decimal places (Rounding up).
Usage

[Link](1.2345, 3, [Link])

Output
1.235

Example 5
Round 1.2345 to three decimal places (Rounding down).
Usage

[Link](1.2345, 3, [Link])

Output
1.234
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional digits as nullable number) as
nullable number

About
Returns the result of rounding number based on the sign of the number. This function will round positive
numbers up and negative numbers down. If digits is specified, number is rounded to the digits number of
decimal digits.

Example 1
Round the number -1.2 away from zero.
Usage

[Link](-1.2)

Output
-2

Example 2
Round the number 1.2 away from zero.
Usage

[Link](1.2)

Output
2

Example 3
Round the number -1.234 to two decimal places away from zero.
Usage

[Link](-1.234, 2)

Output
-1.24
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional digits as nullable number) as nullable
number

About
Returns the result of rounding number down to the previous highest integer. If number is null, this function
returns null. If digits is provided, number is rounded to the specified number of decimal digits.

Example 1
Round down 1.234 to integer.
Usage

[Link](1.234)

Output
1

Example 2
Round down 1.999 to integer.
Usage

[Link](1.999)

Output
1

Example 3
Round down 1.999 to two decimal places.
Usage

[Link](1.999, 2)

Output
1.99
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional digits as nullable number) as
nullable number

About
Returns the result of rounding number based on the sign of the number. This function will round positive
numbers down and negative numbers up. If digits is specified, number is rounded to the digits number of
decimal digits.

Example 1
Round the number -1.2 toward zero.
Usage

[Link](-1.2)

Output
-1

Example 2
Round the number 1.2 toward zero.
Usage

[Link](1.2)

Output
1

Example 3
Round the number -1.234 to two decimal places toward zero.
Usage

[Link](-1.234, 2)

Output
-1.23
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional digits as nullable number) as nullable number

About
Returns the result of rounding number up to the next highest integer. If number is null, this function returns null.
If digits is provided, number is rounded to the specified number of decimal digits.

Example 1
Round up 1.234 to integer.
Usage

[Link](1.234)

Output
2

Example 2
Round up 1.999 to integer.
Usage

[Link](1.999)

Output
2

Example 3
Round up 1.234 to two decimal places.
Usage

[Link](1.234, 2)

Output
1.24
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns 1 for if number is a positive number, -1 if it is a negative number, and 0 if it is zero. If number is null,
[Link] returns null.

Example 1
Determine the sign of 182.
Usage

[Link](182)

Output
1

Example 2
Determine the sign of -182.
Usage

[Link](-182)

Output
-1

Example 3
Determine the sign of 0.
Usage

[Link](0)

Output
0
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the sine of number .

Example 1
Find the sine of the angle 0.
Usage

[Link](0)

Output
0
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the hyperbolic sine of number .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the square root of number . If number is null, [Link] t returns null. If it is a negative value,
[Link] is returned (Not a number).

Example 1
Find the square root of 625.
Usage

[Link](625)

Output
25

Example 2
Find the square root of 85.
Usage

[Link](85)

Output
9.2195444572928871
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the tangent of number .

Example 1
Find the tangent of the angle 1.
Usage

[Link](1)

Output
1.5574077246549023
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable number

About
Returns the hyperbolic tangent of number .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number, optional format as nullable text, optional culture as
nullable text) as nullable text

About
Formats the numeric value number to a text value according to the format specified by format . The format is a
single character code optionally followed by a number precision specifier. The following character codes may be
used for format .
"D" or "d": (Decimal) Formats the result as integer digits. The precision specifier controls the number of digits
in the output.
"E" or "e": (Exponential/scientific) Exponential notation. The precision specifier controls the maximum number
of decimal digits (default is 6).
"F" or "f": (Fixed-point) Integral and decimal digits.
"G" or "g": (General) Most compact form of either fixed-point or scientific.
"N" or "n": (Number) Integral and decimal digits with group separators and a decimal separator.
"P" or "p": (Percent) Number multiplied by 100 and displayed with a percent symbol.
"R" or "r": (Round-trip) A text value that can round-trip an identical number. The precision specifier is ignored.
"X" or "x": (Hexadecimal) A hexadecimal text value.
An optional culture may also be provided (for example, "en-US").

Example 1
Format a number as text without format specified.
Usage

[Link](4)

Output
"4"

Example 2
Format a number as text in Exponential format.
Usage

[Link](4, "e")

Output
"4.000000e+000"

Example 3
Format a number as text in Decimal format with limited precision.
Usage

[Link](-0.1234, "P1")

Output
"-12.3 %"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable number

About
Returns a percentage value from the given value . If the given value is null , [Link] returns
null . If the given value is text with a trailing percent symbol, then the converted decimal number will be
returned. Otherwise, the value will be converted to a number using [Link]. An optional culture may
also be provided (for example, "en-US").

Example 1
Get the percentage value of "12.3%" .
Usage

[Link]("12.3%")

Output
0.123
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable number

About
Returns a Single number value from the given value . If the given value is null , [Link] returns null .
If the given value is number within the range of Single, value is returned, otherwise an error is returned. If
value is of any other type, it will first be converted to a number using [Link]. An optional culture
may also be provided (for example, "en-US").

Example 1
Get the Single number value of "1.5" .
Usage

[Link]("1.5")

Output
1.5
Record functions
9/13/2022 • 2 minutes to read

These functions create and manipulate record values.

Information
NAME DESC RIP T IO N

[Link] Returns the number of fields in a record.

[Link] Returns true if the field name or field names are present in a
record.

Transformations
NAME DESC RIP T IO N

[Link] Translates text representing a geographic value in Well-


Known Text (WKT) format into a structured record.

[Link] Translates a structured geographic point value into its Well-


Known Text (WKT) representation.

[Link] Creates a record representing a geographic point from parts.

[Link] Translates text representing a geometric value in Well-Known


Text (WKT) format into a structured record.

[Link] Translates a structured geometric point value into its Well-


Known Text (WKT) representation.

[Link] Creates a record representing a geometric point from parts.

[Link] Adds a field from a field name and value.

[Link] Combines the records in a list.

[Link] Returns a new record that reorders the given fields with
respect to each other. Any fields not specified remain in their
original locations.

[Link] Returns a new record that renames the fields specified. The
resultant fields will retain their original order. This function
supports swapping and chaining field names. However, all
target names plus remaining field names must constitute a
unique set or an error will occur.
NAME DESC RIP T IO N

[Link] Returns a new record that reorders fields relative to each


other. Any fields not specified remain in their original
locations. Requires two or more fields.

[Link] Transforms fields by applying transformOperations. For more


more information about values supported by
transformOperations, go to Parameter Values.

Selection
NAME DESC RIP T IO N

[Link] Returns the value of the given field. This function can be
used to dynamically create field lookup syntax for a given
record. In that way it is a dynamic version of the record[field]
syntax.

[Link] Returns a list of field names in order of the record's fields.

[Link] Returns the value of a field from a record, or the default


value if the field does not exist.

[Link] Returns a list of field values in order of the record's fields.

[Link] Returns a new record that contains the fields selected from
the input record. The original order of the fields is
maintained.

Serialization
NAME DESC RIP T IO N

[Link] Returns a record given a list of field values and a set of fields.

[Link] Returns a record from a table of records containing field


names and values.

[Link] Returns a list of values containing the field values of the


input record.

[Link] Returns a table of records containing field names and values


from an input record.

Parameter Values
The following type definitions are used to describe the parameter values that are referenced in the Record
functions above.

T Y P E DEF IN IT IO N DESC RIP T IO N

MissingField option More information: [Link]


T Y P E DEF IN IT IO N DESC RIP T IO N

Transform operations Transform operations can be specified by either of the


following values:

• A list value of two items, first item being the field name
and the second item being the transformation function
applied to that field to produce a new value.

• A list of transformations can be provided by providing a


list value, and each item being the list value of 2 items as
described above.

For examples, go to the description of


[Link]

Rename operations Rename operations for a record can be specified as either of:

A single rename operation, which is represented by a list of


two field names, old and new.

For examples, go to the description of [Link].


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](input as nullable text) as nullable record

About
Translates text representing a geographic value in Well-Known Text (WKT) format into a structured record. WKT
is a standard format defined by the Open Geospatial Consortium (OGC) and is the typical serialization format
used by databases including SQL Server.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](input as nullable record, optional omitSRID as nullable logical) as
nullable text

About
Translates a structured geographic point value into its Well-Known Text (WKT) representation as defined by the
Open Geospatial Consortium (OGC), also the serialization format used by many databases including SQL Server.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](longitude as number, latitude as number, optional z as nullable number,
optional m as nullable number, optional srid as nullable number) as record

About
Creates a record representing a geographic point from its constituent parts, such as longitude, latitude, and if
present, elevation (Z) and measure (M). An optional spatial reference identifier (SRID) can be given if different
from the default value (4326).
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](input as nullable text) as nullable record

About
Translates text representing a geometric value in Well-Known Text (WKT) format into a structured record. WKT is
a standard format defined by the Open Geospatial Consortium (OGC) and is the typical serialization format used
by databases including SQL Server.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](input as nullable record, optional omitSRID as nullable logical) as
nullable text

About
Translates a structured geometric point value into its Well-Known Text (WKT) representation as defined by the
Open Geospatial Consortium (OGC), also the serialization format used by many databases including SQL Server.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](x as number, y as number, optional z as nullable number, optional m as
nullable number, optional srid as nullable number) as record

About
Creates a record representing a geometric point from its constituent parts, such as X coordinate, Y coordinate,
and if present, Z coordinate and measure (M). An optional spatial reference identifier (SRID) can be given if
different from the default value (0).
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, fieldName as text, value as any, optional delayed as nullable
logical) as record

About
Adds a field to a record record , given the name of the field fieldName and the value value .

Example 1
Add the field Address to the record.
Usage

[Link]([CustomerID = 1, Name = "Bob", Phone = "123-4567"], "Address", "123 Main St.")

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567", Address = "123 Main St."]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](records as list) as record

About
Combines the records in the given records . If the records contains non-record values, an error is returned.

Example 1
Create a combined record from the records.
Usage

[Link]({
[CustomerID = 1, Name = "Bob"],
[Phone = "123-4567"]
})

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, field as text) as any

About
Returns the value of the specified field in the record . If the field is not found, an exception is thrown.

Example 1
Find the value of field "CustomerID" in the record.
Usage

[Link]([CustomerID = 1, Name = "Bob", Phone = "123-4567"], "CustomerID")

Output
1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record) as number

About
Returns the number of fields in the record record .

Example 1
Find the number of fields in the record.
Usage

[Link]([CustomerID = 1, Name = "Bob"])

Output
2
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record) as list

About
Returns the names of the fields in the record record as text.

Example 1
Find the names of the fields in the record.
Usage

[Link]([OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0])

Output
{"OrderID", "CustomerID", "Item", "Price"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as nullable record, field as text, optional defaultValue as any) as
any

About
Returns the value of the specified field field in the record record . If the field is not found, the optional
defaultValue is returned.

Example 1
Find the value of field "Phone" in the record, or return null if it doesn't exist.
Usage

[Link]([CustomerID = 1, Name = "Bob"], "Phone")

Output
null

Example 2
Find the value of field "Phone" in the record, or return the default if it doesn't exist.
Usage

[Link]([CustomerID = 1, Name = "Bob"], "Phone", "123-4567")

Output
"123-4567"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record) as list

About
Returns a list of the field values in record record .

Example 1
Find the field values in the record.
Usage

[Link]([CustomerID = 1, Name = "Bob", Phone = "123-4567"])

Output
{1, "Bob", "123-4567"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, fields as any) as record

About
Returns a record given a list of field values and a set of fields. The fields can be specified either by a list of
text values, or a record type. An error is thrown if the fields are not unique.

Example 1
Build a record from a list of field values and a list of field names.
Usage

[Link]({1, "Bob", "123-4567"}, {"CustomerID", "Name", "Phone"})

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]

Example 2
Build a record from a list of field values and a record type.
Usage

[Link]({1, "Bob", "123-4567"}, type [CustomerID = number, Name = text, Phone = number])

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as record

About
Returns a record from a table of records table containing field names and value names
{[Name = name, Value = value]} . An exception is thrown if the field names are not unique.

Example 1
Create a record from the table of the form [Link]({[Name = "CustomerID", Value = 1], [Name =
"Name", Value = "Bob"], [Name = "Phone", Value = "123-4567"]}).
Usage

[Link](
[Link]({
[Name = "CustomerID", Value = 1],
[Name = "Name", Value = "Bob"],
[Name = "Phone", Value = "123-4567"]
})
)

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, fields as any) as logical

About
Indicates whether the record record has the fields specified in fields , by returning a logical value (true or
false). Multiple field values can be specified using a list.

Example 1
Check if the record has the field "CustomerID".
Usage

[Link]([CustomerID = 1, Name = "Bob", Phone = "123-4567"], "CustomerID")

Output
true

Example 2
Check if the record has the field "CustomerID" and "Address".
Usage

[Link]([CustomerID = 1, Name = "Bob", Phone = "123-4567"], {"CustomerID", "Address"})

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, fields as any, optional missingField as nullable number)
as record

About
Returns a record that removes all the fields specified in list fields from the input record . If the field specified
does not exist, an exception is thrown.

Example 1
Remove the field "Price" from the record.
Usage

[Link]([CustomerID = 1, Item = "Fishing rod", Price = 18.00], "Price")

Output
[CustomerID = 1, Item = "Fishing rod"]

Example 2
Remove the fields "Price" and "Item" from the record.
Usage

[Link]([CustomerID = 1, Item = "Fishing rod", Price = 18.00], {"Price", "Item"})

Output
[CustomerID = 1]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, renames as list, optional missingField as nullable number)
as record

About
Returns a record after renaming fields in the input record to the new field names specified in list renames . For
multiple renames, a nested list can be used ({ {old1, new1}, {old2, new2} }.

Example 1
Rename the field "UnitPrice" to "Price" from the record.
Usage

[Link](
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", UnitPrice = 100.0],
{"UnitPrice", "Price"}
)

Output
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]

Example 2
Rename the fields "UnitPrice" to "Price" and "OrderNum" to "OrderID" from the record.
Usage

[Link](
[OrderNum = 1, CustomerID = 1, Item = "Fishing rod", UnitPrice = 100.0],
{
{"UnitPrice", "Price"},
{"OrderNum", "OrderID"}
}
)

Output
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, fieldOrder as list, optional missingField as nullable
number) as record

About
Returns a record after reordering the fields in record in the order of fields specified in list fieldOrder . Field
values are maintained and fields not listed in fieldOrder are left in their original position.

Example 1
Reorder some of the fields in the record.
Usage

[Link](
[CustomerID = 1, OrderID = 1, Item = "Fishing rod", Price = 100.0],
{"OrderID", "CustomerID"}
)

Output
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, fields as any, optional missingField as nullable number)
as record

About
Returns a record which includes only the fields specified in list fields from the input record .

Example 1
Select the fields "Item" and "Price" in the record.
Usage

[Link](
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
{"Item", "Price"}
)

Output
[Item = "Fishing rod", Price = 100]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record) as list

About
Returns a list of values containing the field values from the input record .

Example 1
Extract the field values from a record.
Usage

[Link]([A = 1, B = 2, C = 3])

Output
{1, 2, 3}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record) as table

About
Returns a table containing the columns Name and Value with a row for each field in record .

Example 1
Return the table from the record.
Usage

[Link]([OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0])

Output

[Link]({
[Name = "OrderID", Value = 1],
[Name = "CustomerID", Value = 1],
[Name = "Item", Value = "Fishing rod"],
[Name = "Price", Value = 100]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](record as record, transformOperations as list, optional missingField as
nullable number) as record

About
Returns a record after applying transformations specified in list transformOperations to record . One or more
fields may be transformed at a given time.
In the case of a single field being transformed, transformOperations is expected to be a list with two items. The
first item in transformOperations specifies a field name, and the second item in transformOperations specifies
the function to be used for transformation. For example, {"Quantity", [Link]}
In the case of a multiple fields being transformed, transformOperations is expected to be a list of lists, where
each inner list is a pair of field name and transformation operation. For example,
{{"Quantity",[Link]},{"UnitPrice", [Link]}}

Example 1
Convert "Price" field to number.
Usage

[Link](
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = "100.0"],
{"Price", [Link]}
)

Output
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100]

Example 2
Convert "OrderID" and "Price" fields to numbers.
Usage

[Link](
[OrderID = "1", CustomerID = 1, Item = "Fishing rod", Price = "100.0"],
{{"OrderID", [Link]}, {"Price", [Link]}}
)

Output
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100]
Replacer functions
9/13/2022 • 2 minutes to read

These functions are used by other functions in the library to replace a given value.

NAME DESC RIP T IO N

[Link] This function be provided to [Link] or


[Link] to do replace of text values in list and
table values respectively.

[Link] This function be provided to [Link] or


[Link] to do replace values in list and table
values respectively.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, old as text, new as text) as nullable text

About
Replaces the text in the original text with the
old new text. This replacer function can be used in
[Link] and [Link] .

Example 1
Replace the text "hE" with "He" in the string "hEllo world".
Usage

[Link]("hEllo world", "hE", "He")

Output
"Hello world"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, old as any, new as any) as any

About
Replaces the value in the original value with the
old new value. This replacer function can be used in
[Link] and [Link] .

Example 1
Replace the value 11 with the value 10.
Usage

[Link](11, 11, 10)

Output
10
Splitter functions
9/13/2022 • 2 minutes to read

These functions split text.

NAME DESC RIP T IO N

[Link] Returns a function that does no splitting, returning its


argument as a single element list.

[Link] Returns a function that splits text into a list of text according
to a transition from one kind of character to another.

[Link] Returns a function that splits text by any supported


delimiter.

[Link] Returns a function that will split text according to a delimiter.

[Link] Returns a function that splits text by each delimiter in turn.

[Link] Returns a function that splits text according to the specified


lengths.

[Link] Returns a function that splits text according to the specified


positions.

[Link] Returns a function that splits text according to the specified


ranges.

[Link] Returns a function that splits text into a list of text after the
specified length repeatedly.

[Link] Returns a function that splits text according to whitespace.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as function

About
Returns a function that does no splitting, returning its argument as a single element list.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](delimiters as list, optional quoteStyle as nullable number,
optional startAtEnd as nullable logical) as function

About
Returns a function that splits text into a list of text at any of the specified delimiters.

Example 1
Split the input by comma or semicolon, ignoring quotes and quoted delimiters and starting from the beginning
of the input.
Usage

[Link]({",", ";"}, [Link])("a,b;""c,d;e"",f")

Output
{"a", "b", "c,d;e", "f"}

Example 2
Split the input by comma or semicolon, ignoring quotes and quoted delimiters and starting from the end of the
input.
Usage

let
startAtEnd = true
in
[Link]({",", ";"}, [Link], startAtEnd)("a,""b;c,d")

Output
{"a,b", "c", "d"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](before as anynonnull, after as anynonnull) as function

About
Returns a function that splits text into a list of text according to a transition from one kind of character to
another. The before and after parameters can either be a list of characters, or a function that takes a character
and returns true/false.

Example 1
Split the input whenever an upper or lowercase letter is followed by a digit.
Usage

[Link]({"A".."Z", "a".."z"}, {"0".."9"})("Abc123")

Output
{"Abc", "123"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](delimiter as text, optional quoteStyle as nullable number) as
function

About
Returns a function that splits text into a list of text according to the specified delimiter.

Example 1
Split the input by comma, ignoring quoted commas.
Usage

[Link](",", [Link])("a,""b,c"",d")

Output
{"a", "b,c", "d"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](delimiters as list, optional quoteStyle as nullable number,
optional startAtEnd as nullable logical) as function

About
Returns a function that splits text into a list of text at each specified delimiter in sequence.

Example 1
Split the input by comma, then semicolon, starting from the beginning of the input.
Usage

[Link]({",", ";"})("a,b;c,d")

Output
{"a", "b", "c,d"}

Example 2
Split the input by comma, then semicolon, treating quotes like any other character and starting from the end of
the input.
Usage

let
startAtEnd = true
in
[Link]({",", ";"}, [Link], startAtEnd)("a,""b;c"",d")

Output
{"a,""b", "c""", "d"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lengths as list, optional startAtEnd as nullable logical) as
function

About
Returns a function that splits text into a list of text by each specified length.

Example 1
Split the input into the first two characters followed by the next three, starting from the beginning of the input.
Usage

[Link]({2, 3})("AB123")

Output
{"AB", "123"}

Example 2
Split the input into the first three characters followed by the next two, starting from the end of the input.
Usage

let
startAtEnd = true
in
[Link]({5, 2}, startAtEnd)("RedmondWA98052")

{"WA", "98052"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](positions as list, optional startAtEnd as nullable logical) as
function

About
Returns a function that splits text into a list of text at each specified position.

Example 1
Split the input at the specified positions, starting from the beginning of the input.
Usage

[Link]({0, 3, 4})("ABC|12345")

Output
{"ABC", "|", "12345"}

Example 2
Split the input at the specified positions, starting from the end of the input.
Usage

let
startAtEnd = true
in
[Link]({0, 5}, startAtEnd)("Redmond98052")

Output
{"Redmond", "98052"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](ranges as list, optional startAtEnd as nullable logical) as function

About
Returns a function that splits text into a list of text according to the specified offsets and lengths. A null length
indicates that all remaining input should be included.

Example 1
Split the input by the specified position and length pairs, starting from the beginning of the input. Note that the
ranges in this example overlap.
Usage

[Link]({{0, 4}, {2, 10}})("codelimiter")

Output
{"code", "delimiter"}

Example 2
Split the input by the specified position and length pairs, starting from the end of the input.
Usage

let
startAtEnd = true
in
[Link]({{0, 5}, {6, 2}}, startAtEnd)("RedmondWA?98052")

Output
{"WA", "98052"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](length as number, optional startAtEnd as nullable logical)
as function

About
Returns a function that splits text into a list of text after the specified length repeatedly.

Example 1
Repeatedly split the input into chunks of three characters, starting from the beginning of the input.
Usage

[Link](3)("12345678")

Output
{"123", "456", "78"}

Example 2
Repeatedly split the input into chunks of three characters, starting from the end of the input.
Usage

let
startAtEnd = true
in
[Link](3, startAtEnd)("87654321")

Output
{"87", "654", "321"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](optional quoteStyle as nullable number) as function

About
Returns a function that splits text into a list of text at whitespace.

Example 1
Split the input by whitespace characters, treating quotes like any other character.
Usage

[Link]([Link])("a b#(tab)c")

Output
{"a", "b", "c"}
Table functions
9/13/2022 • 11 minutes to read

These functions create and manipulate table values.

Table construction
NAME DESC RIP T IO N

[Link] Returns the abstract syntax tree (AST) for the body of a
function.

[Link] An abstract syntax tree (AST) node representing the item in


an item expression.

[Link] Returns an abstract syntax tree (AST) that represents access


to a column within a row expression.

[Link] Returns the abstract syntax tree (AST) for the body of a
function.

[Link] An abstract syntax tree (AST) node representing the row in a


row expression.

[Link] Returns a table from a list containing nested lists with the
column names and values.

[Link] Converts a list into a table by applying the specified splitting


function to each item in the list.

[Link] Returns a table from a list of records.

[Link] Creates a table from the list where each element of the list is
a list that contains the column values for a single row.

[Link] Returns a table with a column containing the provided value


or list of values.

[Link] Groups the rows of a table by fuzzily matching values in the


specified column for each row.

[Link] Joins the rows from the two tables that fuzzy match based
on the given keys.

[Link] Performs a fuzzy join between tables on supplied columns


and produces the join result in a new column.

[Link] Splits the specified table into a list of tables using the
specified page size.
NAME DESC RIP T IO N

[Link] Creates or extends a table with user-defined handlers for


query and action operations.

[Link] Creates a function that can be intercepted by a handler


defined on a view (via [Link]).

[Link] Creates a modified error record which won't trigger a fallback


when thrown by a handler defined on a view (via
[Link] )

Conversions
NAME DESC RIP T IO N

[Link] Returns a list of nested lists each representing a column of


values in the input table.

[Link] Returns a table into a list by applying the specified


combining function to each row of values in a table.

[Link] Returns a list of records from an input table.

[Link] Returns a nested list of row values from an input table.

Information
NAME DESC RIP T IO N

[Link] Returns the approximate number of rows in the table.

[Link] Returns the number of columns in a table.

[Link] Returns true if the table does not contain any rows.

[Link] Returns a profile of the columns of a table.

[Link] Returns the number of rows in a table.

[Link] Returns a table containing a description of the columns (i.e.


the schema) of the specified table.

[Link] Returns the relationships among a set of tables.

Row operations
NAME DESC RIP T IO N

[Link] Returns a table containing an alternating pattern of the rows


from a table.
NAME DESC RIP T IO N

[Link] Returns a table that is the result of merging a list of tables.


The tables must all have the same row type structure.

[Link] Returns a table containing only the rows that have the
specified text within one of their cells or any part thereof.

[Link] Returns the first row from a table.

[Link] Returns the first row(s) of a table, depending on the


countOrCondition parameter.

[Link] Returns the first column of the first row of the table or a
specified default value.

[Link] Returns a table that is the result of combining a set of


partitioned tables into new columns. The type of the column
can optionally be specified, the default is any.

[Link] Returns a table with the list of rows inserted into the table at
an index. Each row to insert must match the row type of the
table..

[Link] Returns the last row of a table.

[Link] Returns the last row(s) from a table, depending on the


countOrCondition parameter.

[Link] Returns true if all of the rows in a table meet a condition.

[Link] Returns true if any of the rows in a table meet a condition.

[Link] Partitions the table into a list of groups number of tables,


based on the value of the column of each row and a hash
function. The hash function is applied to the value of the
column of a row to obtain a hash value for the row. The hash
value modulo groups determines in which of the returned
tables the row will be placed.

[Link] Returns information about how a table is partitioned.

[Link] Returns the specified number of rows from a table starting


at an offset.

[Link] Returns a table with the specified number of rows removed


from the table starting at the first row. The number of rows
removed depends on the optional countOrCondition
parameter.

[Link] Returns a table with the specified number of rows removed


from the table starting at the last row. The number of rows
removed depends on the optional countOrCondition
parameter.
NAME DESC RIP T IO N

[Link] Returns a table with the specified number of rows removed


from the table starting at an offset.

[Link] Returns a table with all rows removed from the table that
contain an error in at least one of the cells in a row.

[Link] Returns a table containing the rows of the table repeated the
count number of times.

[Link] Returns a table where the rows beginning at an offset and


continuing for count are replaced with the provided rows.

[Link] Returns a table with the rows in reverse order.

[Link] Returns a table containing only the rows that match a


condition.

[Link] Returns a table with only the rows from table that contain an
error in at least one of the cells in a row.

[Link] Returns a single row from a table.

[Link] Returns a table that does not contain the first row or rows of
the table.

[Link] Returns a list containing the first count rows specified and
the remaining rows.

Column operations
NAME DESC RIP T IO N

[Link] Returns the values from a column in a table.

[Link] Returns the names of columns from a table.

[Link] Returns a list with the names of the columns that match the
specified types.

[Link] Demotes the header row down into the first row of a table.

[Link] Duplicates a column with the specified name. Values and


type are copied from the source column.

[Link] Returns true if a table has the specified column or columns.

[Link] Given a table and attribute column containing pivotValues,


creates new columns for each of the pivot values and assigns
them values from the valueColumn. An optional
aggregationFunction can be provided to handle multiple
occurrence of the same key value in the attribute column.
NAME DESC RIP T IO N

[Link] Returns a table where the columns have all been prefixed
with a text value.

[Link] Promotes the first row of the table into its header or column
names.

[Link] Returns a table without a specific column or columns.

[Link] Returns a table with specific columns in an order relative to


one another.

[Link] Returns a table with the columns renamed as specified.

[Link] Returns a table that contains only specific columns.

[Link] Transforms column names by using the given function.

[Link] Given a list of table columns, transforms those columns into


attribute-value pairs.

[Link] Translates all columns other than a specified set into


attribute-value pairs, combined with the rest of the values in
each row.

Transformation
NAME DESC RIP T IO N

[Link] Adds a column named newColumnName to a table.

[Link] Adds a new column with representative values obtained by


fuzzy grouping values of the specified column in the table.

[Link] Returns a table with a new column with a specific name that,
for each row, contains an index of the row in the table.

[Link] Performs a nested join between table1 and table2 from


specific columns and produces the join result as a
newColumnName column for each row of table1.

[Link] Adds a key to table.

[Link] Aggregates tables nested in a specific column into multiple


columns containing aggregate values for those tables.

[Link] [Link] merges columns using a combiner


function to produce a new column. [Link] is
the inverse of [Link].
NAME DESC RIP T IO N

[Link] Combines the specified columns into a new record-valued


column where each record has field names and values
corresponding to the column names and values of the
columns that were combined.

[Link] This function is intended for internal use only.

[Link] Given a column of lists in a table, create a copy of a row for


each value in its list.

[Link] Expands a column of records into columns with each of the


values.

[Link] Expands a column of records or a column of tables into


multiple columns in the containing table.

[Link] Replaces null values in the specified column or columns of


the table with the most recent non-null value in the column.

[Link] Returns a table from the table specified where the value of
the next cell is propagated to the null values cells above in
the column specified.

[Link] This function is intended for internal use only.

[Link] Groups table rows by the values of key columns for each
row.

[Link] Joins the rows of table1 with the rows of table2 based on
the equality of the values of the key columns selected by
table1, key1 and table2, key2.

[Link] Returns the keys of the specified table.

[Link] Joins the rows of the tables based on the equality of the
keys. The results are entered into a new column.

[Link] Replaces the error values in the specified columns with the
corresponding specified value.

[Link] Replaces the keys of the specified table.

[Link] This function is intended for internal use only.

[Link] Replaces oldValue with newValue in specific columns of a


table, using the provided replacer function, such as
[Link] or [Link].

[Link] Returns a new set of columns from a single column applying


a splitter function to each value.

[Link] Transforms the values of one or more columns.


NAME DESC RIP T IO N

[Link] Transforms the column types from a table using a type.

[Link] Transforms the rows from a table using a transform function.

[Link] Returns a table with columns converted to rows and rows


converted to columns from the input table.

Membership
NAME DESC RIP T IO N

[Link] Determines whether the a record appears as a row in the


table.

[Link] Determines whether all of the specified records appear as


rows in the table.

[Link] Determines whether any of the specified records appear as


rows in the table.

[Link] Removes duplicate rows from a table, ensuring that all


remaining rows are distinct.

[Link] Determines whether a table contains only distinct rows.

[Link] Determines the position or positions of a row within a table.

[Link] Determines the position or positions of any of the specified


rows within the table.

[Link] Removes all occurrences of rows from a table.

[Link] Replaces specific rows from a table with the new rows.

Ordering
NAME DESC RIP T IO N

[Link] Returns the largest row or rows from a table using a


comparisonCriteria.

[Link] Returns the largest N rows from a table. After the rows are
sorted, the countOrCondition parameter must be specified
to further filter the result.

[Link] Returns the smallest row or rows from a table using a


comparisonCriteria.

[Link] Returns the smallest N rows in the given table. After the
rows are sorted, the countOrCondition parameter must be
specified to further filter the result.
NAME DESC RIP T IO N

[Link] Appends a column with the ranking of one or more other


columns.

[Link] Sorts the rows in a table using a comparisonCriteria or a


default ordering if one is not specified.

Other
NAME DESC RIP T IO N

[Link] Buffers a table into memory, isolating it from external


changes during evaluation.

Parameter Values
Naming output columns
This parameter is a list of text values specifying the column names of the resulting table. This parameter is
generally used in the Table construction functions, such as [Link] and [Link].
Comparison criteria
Comparison criterion can be provided as either of the following values:
A number value to specify a sort order. More information: Sort order
To compute a key to be used for sorting, a function of one argument can be used.
To both select a key and control order, comparison criterion can be a list containing the key and order.
To completely control the comparison, a function of two arguments can be used that returns -1, 0, or 1
given the relationship between the left and right inputs. [Link] can be used to delegate this logic.
For examples, go to the description of [Link].
Count or Condition criteria
This criteria is generally used in ordering or row operations. It determines the number of rows returned in the
table and can take two forms, a number or a condition.
A number indicates how many values to return inline with the appropriate function.
If a condition is specified, the rows containing values that initially meet the condition is returned. Once a
value fails the condition, no further values are considered.
More information: [Link], [Link]
Handling of extra values
Extra values are used to indicate how the function should handle extra values in a row. This parameter is
specified as a number, which maps to the following options:
[Link] = 0 [Link] = 1 [Link] = 2

More information: [Link], [Link]


Missing column handling
This parameter is used to indicate how the function should handle missing columns. This parameter is specified
as a number, which maps to the following options:
[Link] = 0 [Link] = 1 [Link] = 2;

This parameter is used in column or transformation operations, for examples, in [Link]. More
information: [Link]
Sort Order
Sort ordering is used to indicate how the results should be sorted. This parameter is specified as a number,
which maps to the following options:
[Link] = 0 [Link] = 1

More information: [Link]


Equation criteria
Equation criteria for tables can be specified as either:
A function value that is either:
A key selector that determines the column in the table to apply the equality criteria.
A comparer function that is used to specify the kind of comparison to apply. Built-in comparer
functions can be specified. More information: Comparer functions
A list of the columns in the table to apply the equality criteria.
For examples, go to the description of [Link].
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function) as record

About
Returns the abstract syntax tree (AST) for the body of function , normalized into an item expression:
The function must be a 1-argument lambda.
All references to the function parameter are replaced with [Link] .
The AST will be simplified to contain only nodes of the kinds:
Constant
Invocation
Unary
Binary
If
FieldAccess
NotImplemented

An error is raised if an item expression AST cannot be returned for the body of function .

Example 1
Returns the AST for the body of the function each _ <> null

Usage

[Link](each _ <> null)

Output

[
Kind = "Binary",
Operator = "NotEquals",
Left = [Link],
Right =
[
Kind = "Constant",
Value = null
]
]
[Link]
9/13/2022 • 2 minutes to read

About
An abstract syntax tree (AST) node representing the item in an item expression.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](columnName as text) as record

About
Returns an abstract syntax tree (AST) that represents access to column columnName of the row within a row
expression.

Example 1
Creates an AST representing access of column "CustomerName".
Usage

[Link]("CustomerName")

Output

[
Kind = "FieldAccess",
Expression = [Link],
MemberName = "CustomerName"
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function) as record

About
Returns the abstract syntax tree (AST) for the body of function , normalized into a row expression:
The function must be a 1-argument lambda.
All references to the function parameter are replaced with [Link] .
All references to columns are replaced with [Link](columnName) .
The AST will be simplified to contain only nodes of the kinds:
Constant
Invocation
Unary
Binary
If
FieldAccess
NotImplemented

An error is raised if a row expression AST cannot be returned for the body of function .

Example 1
Returns the AST for the body of the function each [CustomerID] = "ALFKI"
Usage

[Link](each [CustomerName] = "ALFKI")

Output

[
Kind = "Binary",
Operator = "Equals",
Left = [Link]("CustomerName"),
Right =
[
Kind = "Constant",
Value = "ALFKI"
]
]
[Link]
9/13/2022 • 2 minutes to read

About
An abstract syntax tree (AST) node representing the row in a row expression.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, newColumnName as text, columnGenerator as function, optional
columnType as nullable type) as table

About
Adds a column named newColumnName to the table table . The values for the column are computed using the
specified selection function columnGenerator with each row taken as an input.

Example 1
Add a column named "TotalPrice" to the table with each value being the sum of column [Price] and column
[Shipping].
Usage

[Link](
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0, Shipping = 10.00],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0, Shipping = 15.00],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0, Shipping = 10.00]
}),
"TotalPrice",
each [Price] + [Shipping]
)

Output

[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100, Shipping = 10, TotalPrice = 110],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5, Shipping = 15, TotalPrice = 20],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25, Shipping = 10, TotalPrice = 35]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columnName as text, newColumnName as text, optional
options as nullable record) as table

About
Adds a new column newColumnName to table with representative values of columnName . The representatives are
obtained by fuzzily matching values in columnName , for each row.

An optional set of options may be included to specify how to compare the key columns. Options include:
Culture : Allows grouping records based on culture-specific rules. It can be any valid culture name. For
example, a Culture option of "ja-JP" groups records based on the Japanese culture. The default value is "",
which groups based on the Invariant English culture.
IgnoreCase : A logical (true/false) value that allows case-insensitive key grouping. For example, when true,
"Grapes" is grouped with "grapes". The default value is true.
IgnoreSpace : A logical (true/false) value that allows combining of text parts in order to find groups. For
example, when true, "Gra pes" is grouped with "Grapes". The default value is true.
SimilarityColumnName : A name for the column that shows the similarity between an input value and the
representative value for that input. The default value is null, in which case a new column for similarities will
not be added.
Threshold : A number between 0.00 and 1.00 that specifies the similarity score at which two values will be
grouped. For example, "Grapes" and "Graes" (missing "p") are grouped together only if this option is set to
less than 0.90. A threshold of 1.00 is the same as specifying an exact match criteria while grouping. The
default value is 0.80.
TransformationTable : A table that allows grouping records based on custom value mappings. It should
contain "From" and "To" columns. For example, "Grapes" is grouped with "Raisins" if a transformation table is
provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that
the transformation will be applied to all occurrences of the text in the transformation table. With the above
transformation table, "Grapes are sweet" will also be grouped with "Raisins are sweet".
Example 1
Find the representative values for the location of the employees.
Usage
[Link](
[Link](
{
[EmployeeID = 1, Location = "Seattle"],
[EmployeeID = 2, Location = "seattl"],
[EmployeeID = 3, Location = "Vancouver"],
[EmployeeID = 4, Location = "Seatle"],
[EmployeeID = 5, Location = "vancover"],
[EmployeeID = 6, Location = "Seattle"],
[EmployeeID = 7, Location = "Vancouver"]
},
type table [EmployeeID = nullable number, Location = nullable text]
),
"Location",
"Location_Cleaned",
[IgnoreCase = true, IgnoreSpace = true]
)

Output

[Link](
{
[EmployeeID = 1, Location = "Seattle", Location_Cleaned = "Seattle"],
[EmployeeID = 2, Location = "seattl", Location_Cleaned = "Seattle"],
[EmployeeID = 3, Location = "Vancouver", Location_Cleaned = "Vancouver"],
[EmployeeID = 4, Location = "Seatle", Location_Cleaned = "Seattle"],
[EmployeeID = 5, Location = "vancover", Location_Cleaned = "Vancouver"],
[EmployeeID = 6, Location = "Seattle", Location_Cleaned = "Seattle"],
[EmployeeID = 7, Location = "Vancouver", Location_Cleaned = "Vancouver"]
},
type table [EmployeeID = nullable number, Location = nullable text, Location_Cleaned = nullable text]
)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, newColumnName as text, optional initialValue as nullable
number, optional increment as nullable number, optional columnType as nullable type) as table

About
Appends a column named newColumnName to the table with explicit position values. An optional value,
initialValue , the initial index value. An optional value, increment , specifies how much to increment each index
value.

Example 1
Add an index column named "Index" to the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"Index"
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567", Index = 0],
[CustomerID = 2, Name = "Jim", Phone = "987-6543", Index = 1],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", Index = 2],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550", Index = 3]
})

Example 2
Add an index column named "index", starting at value 10 and incrementing by 5, to the table.
Usage
[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"Index",
10,
5
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567", Index = 10],
[CustomerID = 2, Name = "Jim", Phone = "987-6543", Index = 15],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", Index = 20],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550", Index = 25]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table1 as table, key1 as any, table2 as function, key2 as any, newColumnName
as text) as table

About
Joins the rows of table1 with the rows of table2 based on the equality of the values of the key columns
selected by key1 (for table1 ) and key2 (for table2 ). The results are entered into the column named
newColumnName . This function behaves similarly to [Link] with a JoinKind of LeftOuter except that the join
results are presented in a nested rather than flattened fashion.

Example 1
Add a join column to ({[saleID = 1, item = "Shirt"], [saleID = 2, item = "Hat"]}) named "price/stock" from the
table ({[saleID = 1, price = 20], [saleID = 2, price = 10]}) joined on [saleID].
Usage

[Link](
[Link]({
[saleID = 1, item = "Shirt"],
[saleID = 2, item = "Hat"]
}),
"saleID",
() => [Link]({
[saleID = 1, price = 20, stock = 1234],
[saleID = 2, price = 10, stock = 5643]
}),
"saleID",
"price"
)

Output

[Link]({
[
saleID = 1,
item = "Shirt",
price = [Link]({[saleID = 1, price = 20, stock = 1234]})
],
[
saleID = 2,
item = "Hat",
price = [Link]({[saleID = 2, price = 10, stock = 5643]})
]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columns as list, isPrimary as logical) as table

About
Adds a key to table , where columns is the list of column names that define the key, and isPrimary specifies
whether the key is primary.

Example 1
Add a single-column primary key to a table.
Usage

let
table = [Link]({
[Id = 1, Name = "Hello There"],
[Id = 2, Name = "Good Bye"]
}),
resultTable = [Link](table, {"Id"}, true)
in
resultTable

Output

[Link]({
[Id = 1, Name = "Hello There"],
[Id = 2, Name = "Good Bye"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, newColumnName as text, comparisonCriteria as any, optional
options as nullable record) as table

About
Appends a column named newColumnName to the table with the ranking of one or more other columns
described by comparisonCriteria . The RankKind option in options can be used by advanced users to pick a
more-specific ranking method.

Example 1
Add a column named RevenueRank to the table which ranks the Revenue column from highest to lowest.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Revenue = 200],
[CustomerID = 2, Name = "Jim", Revenue = 100],
[CustomerID = 3, Name = "Paul", Revenue = 200],
[CustomerID = 4, Name = "Ringo", Revenue = 50]
}),
"RevenueRank",
{"Revenue", [Link]},
[RankKind = [Link]]
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Revenue = 200, RevenueRank = 1],
[CustomerID = 3, Name = "Paul", Revenue = 200, RevenueRank = 1],
[CustomerID = 2, Name = "Jim", Revenue = 100, RevenueRank = 3],
[CustomerID = 4, Name = "Ringo", Revenue = 50, RevenueRank = 4]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, column as text, aggregations as list) as table

About
Aggregates tables in table [ column ] into multiple columns containing aggregate values for the tables.
aggregations is used to specify the columns containing the tables to aggregate, the aggregation functions to
apply to the tables to generate their values, and the names of the aggregate columns to create.

Example 1
Aggregate table columns in [t] in the table {[t = {[a=1, b=2, c=3], [a=2,b=4,c=6]}, b = 2]} into the sum of
[t.a] , the min and max of [t.b] , and the count of values in [t.a] .

Usage

[Link](
[Link](
{
[
t = [Link]({
[a = 1, b = 2, c = 3],
[a = 2, b = 4, c = 6]
}),
b = 2
]
},
type table [t = table [a = number, b = number, c = number], b = number]
),
"t",
{
{"a", [Link], "sum of t.a"},
{"b", [Link], "min of t.b"},
{"b", [Link], "max of t.b"},
{"a", [Link], "count of t.a"}
}
)

Output
[Link]({[#"sum of t.a" = 3, #"min of t.b" = 2, #"max of t.b" = 4, #"count of t.a" = 2, b = 2]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, offset as number, skip as number, take as number) as table

About
Keeps the initial offset then alternates taking and skipping the following rows.
table : The input table.
offset : The number of rows to keep before starting iterations.
skip : The number of rows to remove in each iteration.
take : The number of rows to keep in each iteration.

Example 1
Return a table from the table that, starting at the first row, skips 1 value and then keeps 1 value.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}),
1,
1,
1
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as number

About
Returns the approximate number of rows in the table , or an error if the data source doesn't support
approximation.

Example 1
Estimate the number of distinct combinations of city and state in a large table, which can be used as a cardinality
estimate for the columns. Cardinality estimates are important enough that various data sources (such as SQL
Server) support this particular approximation, often using an algorithm called HyperLogLog.
Usage

[Link]([Link]([Link](sqlTable, {"city", "state"})))

Output
number
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional options as nullable record) as table

About
Buffers a table in memory, isolating it from external changes during evaluation. Buffering is shallow. It forces the
evaluation of any scalar cell values, but leaves non-scalar values (records, lists, tables, and so on) as-is.
Note that using this function might or might not make your queries run faster. In some cases, it can make your
queries run more slowly due to the added cost of reading all the data and storing it in memory, as well as the
fact that buffering prevents downstream folding. If the data doesn't need to be buffered but you just want to
prevent downstream folding, use [Link] instead.

Example 1
Load all the rows of a SQL table into memory, so that any downstream operations will no longer be able to
query the SQL server.
Usage

let
Source = [Link]("SomeSQLServer", "MyDb"),
MyTable = Source{[Item="MyTable"]}[Data],
BufferMyTable = [Link](dbo_MyTable)
in
BufferMyTable

Output

table
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, column as text) as list

About
Returns the column of data specified by column from the table table as a list.

Example 1
Returns the values from the [Name] column in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"Name"
)

Output
{"Bob", "Jim", "Paul", "Ringo"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as number

About
Returns the number of columns in the table table .

Example 1
Find the number of columns in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
)

Output
3
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as list

About
Returns the column names in the table table as a list of text.

Example 1
Find the column names of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
)

Output
{"CustomerID", "Name", "Phone"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, listOfTypes as list) as list

About
Returns a list with the names of the columns from table table that match the types specified in listOfTypes .

Example 1
Return the names of columns of type [Link] from the table.
Usage

[Link](
[Link](
{[a = 1, b = "hello"]},
type table[a = [Link], b = [Link]]
),
{type number}
)

Output
{"a"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](tables as list, optional columns as any) as table

About
Returns a table that is the result of merging a list of tables, tables . The resulting table will have a row type
structure defined by columns or by a union of the input types if columns is not specified.

Example 1
Merge the three tables together.
Usage

[Link]({
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
[Link]({[CustomerID = 2, Name = "Jim", Phone = "987-6543"]}),
[Link]({[CustomerID = 3, Name = "Paul", Phone = "543-7890"]})
})

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Example 2
Merge three tables with different structures.
Usage

[Link]({
[Link]({[Name = "Bob", Phone = "123-4567"]}),
[Link]({[Fax = "987-6543", Phone = "838-7171"]}),
[Link]({[Cell = "543-7890"]})
})

Output
[Link]({
[Name = "Bob", Phone = "123-4567", Fax = null, Cell = null],
[Name = null, Phone = "838-7171", Fax = "987-6543", Cell = null],
[Name = null, Phone = null, Fax = null, Cell = "543-7890"]
})

Example 3
Merge two tables and project onto the given type.
Usage

[Link](
{
[Link]({[Name = "Bob", Phone = "123-4567"]}),
[Link]({[Fax = "987-6543", Phone = "838-7171"]}),
[Link]({[Cell = "543-7890"]})
},
{"CustomerID", "Name"}
)

Output

[Link]({
[CustomerID = null, Name = "Bob"],
[CustomerID = null, Name = null],
[CustomerID = null, Name = null]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, sourceColumns as list, combiner as function, column as
text) as table

About
Combines the specified columns into a new column using the specified combiner function.

Example 1
Combine the last and first names into a new column, separated by a comma.
Usage

[Link](
[Link]({[FirstName = "Bob", LastName = "Smith"]}),
{"LastName", "FirstName"},
[Link](",", [Link]),
"FullName"
)

Output

[Link]({[FullName = "Smith,Bob"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, newColumnName as text, sourceColumns as list,
optional options as nullable record) as table

About
Combines the specified columns of table into a new record-valued column named newColumnName where each
record has field names and values corresponding to the column names and values of the columns that were
combined. If a record is specified for options , the following options may be provided:
DisplayNameColumn : When specified as text, indicates that the given column name should be treated as the
display name of the record. This need not be one of the columns in the record itself.
TypeName : When specified as text, supplies a logical type name for the resulting record which can be used
during data load to drive behavior by the loading environment.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, shapingFunction as function) as table

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, row as record, optional equationCriteria as any) as logical

About
Indicates whether the specified record, row , appears as a row in the table . An optional parameter
equationCriteria may be specified to control comparison between the rows of the table.

Example 1
Determine if the table contains the row.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
[Name = "Bob"]
)

Output
true

Example 2
Determine if the table contains the row.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
[Name = "Ted"]
)

Output
false
Example 3
Determine if the table contains the row comparing only the column [Name].
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
[CustomerID = 4, Name = "Bob"],
"Name"
)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, rows as list, optional equationCriteria as any) as logical

About
Indicates whether all the specified records in the list of records rows , appear as rows in the table . An optional
parameter equationCriteria may be specified to control comparison between the rows of the table.

Example 1
Determine if the table contains all the rows, comparing only the column [CustomerID].
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
{
[CustomerID = 1, Name = "Bill"],
[CustomerID = 2, Name = "Fred"]
},
"CustomerID"
)

Output
true

Example 2
Determine if the table contains all the rows.
Usage
[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
{
[CustomerID = 1, Name = "Bill"],
[CustomerID = 2, Name = "Fred"]
}
)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, rows as list, optional equationCriteria as any) as logical

About
Indicates whether any the specified records in the list of records rows , appear as rows in the table . An
optional parameter equationCriteria may be specified to control comparison between the rows of the table.

Example 1
Determine if the table ({[a = 1, b = 2], [a = 3, b = 4]}) contains the rows [a = 1, b = 2] or
[a = 3, b = 5] .

Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4]
}),
{
[a = 1, b = 2],
[a = 3, b = 5]
}
)

Output
true

Example 2
Determine if the table ({[a = 1, b = 2], [a = 3, b = 4]}) contains the rows [a = 1, b = 3] or
[a = 3, b = 5] .

Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4]
}),
{
[a = 1, b = 3],
[a = 3, b = 5]
}
)

Output
false

Example 3
Determine if the table ([Link]({[a = 1, b = 2], [a = 3, b = 4]})) contains the rows
[a = 1, b = 3] or [a = 3, b = 5] comparing only the column [a].
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4]
}),
{
[a = 1, b = 3],
[a = 3, b = 5]
},
"a"
)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as table

About
Demotes the column headers (i.e. column names) to the first row of values. The default column names are
"Column1", "Column2" and so on.

Example 1
Demote the first row of values in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})
)

Output

[Link]({
[Column1 = "CustomerID", Column2 = "Name", Column3 = "Phone"],
[Column1 = 1, Column2 = "Bob", Column3 = "123-4567"],
[Column1 = 2, Column2 = "Jim", Column3 = "987-6543"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional equationCriteria as any) as table

About
Removes duplicate rows from the table table . An optional parameter, equationCriteria , specifies which
columns of the table are tested for duplication. If equationCriteria is not specified, all columns are tested.

Example 1
Remove the duplicate rows from the table.
Usage

[Link](
[Link]({
[a = "A", b = "a"],
[a = "B", b = "b"],
[a = "A", b = "a"]
})
)

Output

[Link]({
[a = "A", b = "a"],
[a = "B", b = "b"]
})

Example 2
Remove the duplicate rows from column [b] in the table
({[a = "A", b = "a"], [a = "B", b = "a"], [a = "A", b = "b"]}) .
Usage

[Link](
[Link]({
[a = "A", b = "a"],
[a = "B", b = "a"],
[a = "A", b = "b"]
}),
"b"
)

Output
[Link]({
[a = "A", b = "a"],
[a = "A", b = "b"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columnName as text, newColumnName as text, optional
columnType as nullable type) as table

About
Duplicate the column named columnName to the table table . The values and type for the column newColumnName
are copied from column columnName .

Example
Duplicate the column "a" to a column named "copied column" in the table ({[a = 1, b = 2], [a = 3, b = 4]}) .
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4]
}),
"a",
"copied column"
)

Output

[Link]({
[a = 1, b = 2, #"copied column" = 1],
[a = 3, b = 4, #"copied column" = 3]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, column as text) as table

About
Given a table , where a column is a list of values, splits the list into a row for each value. Values in the other
columns are duplicated in each new row created.

Example 1
Split the list column [Name] in the table.
Usage

[Link](
[Link]({[Name = {"Bob", "Jim", "Paul"}, Discount = .15]}),
"Name"
)

Output

[Link]({
[Name = "Bob", Discount = 0.15],
[Name = "Jim", Discount = 0.15],
[Name = "Paul", Discount = 0.15]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, column as text, fieldNames as list, optional
newColumnNames as nullable list) as table

About
Given the column of records in the input table , creates a table with a column for each field in the record.
Optionally, newColumnNames may be specified to ensure unique names for the columns in the new table.
table : The original table with the record column to expand.
column : The column to expand.
fieldNames : The list of fields to expand into columns in the table.
newColumnNames : The list of column names to give the new columns. The new column names cannot duplicate
any column in the new table.

Example 1
Expand column [a] in the table ({[a = [aa = 1, bb = 2, cc = 3], b = 2]}) into 3 columns "aa", "bb" and "cc".
Usage

[Link](
[Link]({
[
a = [aa = 1, bb = 2, cc = 3],
b = 2
]
}),
"a",
{"aa", "bb", "cc"}
)

Output
[Link]({[aa = 1, bb = 2, cc = 3, b = 2]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, column as text, columnNames as list, optional
newColumnNames as nullable list) as table

About
Expands tables in table [ column ] into multiple rows and columns. columnNames is used to select the columns to
expand from the inner table. Specify newColumnNames to avoid conflicts between existing columns and new
columns.

Example 1
Expand table columns in [a] in the table ({[t = {[a=1, b=2, c=3], [a=2,b=4,c=6]}, b = 2]}) into 3 columns
[t.a] , [t.b] and [t.c] .

Usage

[Link](
[Link]({
[
t = [Link]({
[a = 1, b = 2, c = 3],
[a = 2, b = 4, c = 6]
}),
b = 2
]
}),
"t",
{"a", "b", "c"},
{"t.a", "t.b", "t.c"}
)

Output

[Link]({
[t.a = 1, t.b = 2, t.c = 3, b = 2],
[t.a = 2, t.b = 4, t.c = 6, b = 2]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columns as list) as table

About
Returns a table from the table specified where the value of a previous cell is propagated to the null-valued
cells below in the columns specified.

Example 1
Return a table with the null values in column [Place] filled with the value above them from the table.
Usage

[Link](
[Link]({
[Place = 1, Name = "Bob"],
[Place = null, Name = "John"],
[Place = 2, Name = "Brad"],
[Place = 3, Name = "Mark"],
[Place = null, Name = "Tom"],
[Place = null, Name = "Adam"]
}),
{"Place"}
)

Output

[Link]({
[Place = 1, Name = "Bob"],
[Place = 1, Name = "John"],
[Place = 2, Name = "Brad"],
[Place = 3, Name = "Mark"],
[Place = 3, Name = "Tom"],
[Place = 3, Name = "Adam"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columns as list) as table

About
Returns a table from the table specified where the value of the next cell is propagated to the null-valued cells
above in the columns specified.

Example 1
Return a table with the null values in column [Column2] filled with the value below them from the table.
Usage

[Link](
[Link]({
[Column1 = 1, Column2 = 2],
[Column1 = 3, Column2 = null],
[Column1 = 5, Column2 = 3]
}),
{"Column2"}
)

Output

[Link]({
[Column1 = 1, Column2 = 2],
[Column1 = 3, Column2 = 3],
[Column1 = 5, Column2 = 3]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, dataTableIdentifier as text) as any

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, text as text) as table

About
Returns the rows in the table table that contain the text text . If the text is not found, an empty table is
returned.

Example 1
Find the rows in the table that contain "Bob".
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"Bob"
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional default as any) as any

About
Returns the first row of the table or an optional default value, default , if the table is empty.

Example 1
Find the first row of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
)

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]

Example 2
Find the first row of the table ({}) or return [a = 0, b = 0] if empty.
Usage

[Link]([Link]({}), [a = 0, b = 0])

Output
[a = 0, b = 0]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, countOrCondition as any) as table

About
Returns the first row(s) of the table table , depending on the value of countOrCondition :
If countOrCondition is a number, that many rows (starting at the top) will be returned.
If countOrCondition is a condition, the rows that meet the condition will be returned until a row does not
meet the condition.

Example 1
Find the first two rows of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}),
2
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})

Example 2
Find the first rows where [a] > 0 in the table.
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4],
[a = -5, b = -6]
}),
each [a] > 0
)
Output

[Link]({
[a = 1, b = 2],
[a = 3, b = 4]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional default as any) as any

About
Returns the first column of the first row of the table table or a specified default value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](lists as list, optional columns as any) as table

About
Creates a table of type columns from a list lists containing nested lists with the column names and values. If
some columns have more values then others, the missing values will be filled with the default value, 'null', if the
columns are nullable.

Example 1
Return a table from a list of customer names in a list. Each value in the customer list item becomes a row value,
and each list becomes a column.
Usage

[Link]({
{1, "Bob", "123-4567"},
{2, "Jim", "987-6543"},
{3, "Paul", "543-7890"}
})

Output

[Link]({
[Column1 = 1, Column2 = 2, Column3 = 3],
[Column1 = "Bob", Column2 = "Jim", Column3 = "Paul"],
[Column1 = "123-4567", Column2 = "987-6543", Column3 = "543-7890"]
})

Example 2
Create a table from a given list of columns and a list of column names.
Usage

[Link](
{
{1, "Bob", "123-4567"},
{2, "Jim", "987-6543"},
{3, "Paul", "543-7890"}
},
{"CustomerID", "Name", "Phone"}
)

Output
[Link]({
[CustomerID = 1, Name = 2, Phone = 3],
[CustomerID = "Bob", Name = "Jim", Phone = "Paul"],
[CustomerID = "123-4567", Name = "987-6543", Phone = "543-7890"]
})

Example 3
Create a table with different number of columns per row. The missing row value is null.
Usage

[Link](
{
{1, 2, 3},
{4, 5},
{6, 7, 8, 9}
},
{"column1", "column2", "column3"}
)

Output

[Link]({
[column1 = 1, column2 = 4, column3 = 6],
[column1 = 2, column2 = 5, column3 = 7],
[column1 = 3, column2 = null, column3 = 8],
[column1 = null, column2 = null, column3 = 9]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](list as list, optional splitter as nullable function, optional columns as any,
optional default as any, optional extraValues as nullable number) as table

About
Converts a list, list into a table by applying the optional splitting function, splitter , to each item in the list.
By default, the list is assumed to be a list of text values that is split by commas. Optional columns may be the
number of columns, a list of columns or a TableType. Optional default and extraValues may also be specified.

Example 1
Create a table from the list with the column named "Letters" using the default splitter.
Usage

[Link]({"a", "b", "c", "d"}, null, {"Letters"})

Output

[Link]({
[Letters = "a"],
[Letters = "b"],
[Letters = "c"],
[Letters = "d"]
})

Example 2
Create a table from the list using the [Link] splitter with the resulting table having "CustomerID"
and "Name" as column names.
Usage

[Link](
{
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
},
[Link],
{"CustomerID", "Name"}
)

Output
[Link]({
[CustomerID = 1, Name = "Bob"],
[CustomerID = 2, Name = "Jim"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](partitionColumn as text, partitions as list, optional partitionColumnType
as nullable type) as table

About
Returns a table that is the result of combining a set of partitioned tables, partitions . partitionColumn is the
name of the column to add. The type of the column defaults to any , but can be specified by
partitionColumnType .

Example 1
Find item type from the list {number} .
Usage

[Link](
"Year",
{
{
1994,
[Link](
"Month",
{
{
"Jan",
[Link](
"Day",
{
{1, #table({"Foo"}, {{"Bar"}})},
{2, #table({"Foo"}, {{"Bar"}})}
}
)
},
{
"Feb",
[Link](
"Day",
{
{3, #table({"Foo"}, {{"Bar"}})},
{4, #table({"Foo"}, {{"Bar"}})}
}
)
}
}
)
}
}
)

Output
[Link]({
[
Foo = "Bar",
Day = 1,
Month = "Jan",
Year = 1994
],
[
Foo = "Bar",
Day = 2,
Month = "Jan",
Year = 1994
],
[
Foo = "Bar",
Day = 3,
Month = "Feb",
Year = 1994
],
[
Foo = "Bar",
Day = 4,
Month = "Feb",
Year = 1994
]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](records as list, optional columns as any, optional missingField as nullable
number) as table

About
Converts records , a list of records, into a table.

Example 1
Create a table from records, using record field names as column names.
Usage

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Example 2
Create a table from records with typed columns and select the number columns.
Usage

[Link](
[Link](
{[CustomerID = 1, Name = "Bob"]},
type table[CustomerID = [Link], Name = [Link]]
),
{type number}
)

Output
{"CustomerID"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](rows as list, optional columns as any) as table

About
Creates a table from the list rows where each element of the list is an inner list that contains the column values
for a single row. An optional list of column names, a table type, or a number of columns could be provided for
columns .

Example 1
Return a table with column [CustomerID] with values {1, 2}, column [Name] with values {"Bob", "Jim"}, and
column [Phone] with values {"123-4567", "987-6543"}.
Usage

[Link](
{
{1, "Bob", "123-4567"},
{2, "Jim", "987-6543"}
},
{"CustomerID", "Name", "Phone"}

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})

Example 2
Return a table with column [CustomerID] with values {1, 2}, column [Name] with values {"Bob", "Jim"}, and
column [Phone] with values {"123-4567", "987-6543"}, where [CustomerID] is number type, and [Name] and
[Phone] are text types.
Usage

[Link](
{
{1, "Bob", "123-4567"},
{2, "Jim", "987-6543"}
},
type table [CustomerID = number, Name = text, Phone = text]
)
Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional options as nullable record) as table

About
Creates a table with a column containing the provided value or list of values, value . An optional record
parameter, options , may be specified to control the following options:
DefaultColumnName : The column name used when constructing a table from a list or scalar value.

Example 1
Create a table from the value 1.
Usage

[Link](1)

Output
[Link]({[Value = 1]})

Example 2
Create a table from the list.
Usage

[Link]({1, "Bob", "123-4567"})

Output

[Link]({
[Value = 1],
[Value = "Bob"],
[Value = "123-4567"]
})

Example 3
Create a table from the value 1, with a custom column name.
Usage

[Link](1, [DefaultColumnName = "MyValue"])


Output
[Link]({[MyValue = 1]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, key as any, aggregatedColumns as list, optional options as
nullable record) as table

About
Groups the rows of table by fuzzily matching values in the specified column, key , for each row. For each
group, a record is constructed containing the key columns (and their values) along with any aggregated
columns specified by aggregatedColumns . This function cannot guarantee to return a fixed order of rows.
An optional set of options may be included to specify how to compare the key columns. Options include:
Culture : Allows grouping records based on culture-specific rules. It can be any valid culture name. For
example, a Culture option of "ja-JP" groups records based on the Japanese culture. The default value is "",
which groups based on the Invariant English culture.
IgnoreCase : A logical (true/false) value that allows case-insensitive key grouping. For example, when true,
"Grapes" is grouped with "grapes". The default value is true.
IgnoreSpace : A logical (true/false) value that allows combining of text parts in order to find groups. For
example, when true, "Gra pes" is grouped with "Grapes". The default value is true.
SimilarityColumnName : A name for the column that shows the similarity between an input value and the
representative value for that input. The default value is null, in which case a new column for similarities will
not be added.
Threshold : A number between 0.00 and 1.00 that specifies the similarity score at which two values will be
grouped. For example, "Grapes" and "Graes" (missing "p") are grouped together only if this option is set to
less than 0.90. A threshold of 1.00 is the same as specifying an exact match criteria while grouping. The
default value is 0.80.
TransformationTable : A table that allows grouping records based on custom value mappings. It should
contain "From" and "To" columns. For example, "Grapes" is grouped with "Raisins" if a transformation table is
provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that
the transformation will be applied to all occurrences of the text in the transformation table. With the above
transformation table, "Grapes are sweet" will also be grouped with "Raisins are sweet".

Example 1
Group the table adding an aggregate column [Count] that contains the number of employees in each location (
each [Link](_) ).

Usage
[Link](
[Link](
{
[EmployeeID = 1, Location = "Seattle"],
[EmployeeID = 2, Location = "seattl"],
[EmployeeID = 3, Location = "Vancouver"],
[EmployeeID = 4, Location = "Seatle"],
[EmployeeID = 5, Location = "vancover"],
[EmployeeID = 6, Location = "Seattle"],
[EmployeeID = 7, Location = "Vancouver"]
},
type table [EmployeeID = nullable number, Location = nullable text]
),
"Location",
{"Count", each [Link](_)},
[IgnoreCase = true, IgnoreSpace = true]
)

Output

[Link]({
[Location = "Seattle", Count = 4],
[Location = "Vancouver", Count = 3]
})
[Link]
9/13/2022 • 3 minutes to read

Syntax
[Link](table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as
nullable number, optional joinOptions as nullable record) as table

About
Joins the rows of table1 with the rows of table2 based on a fuzzy matching of the values of the key columns
selected by key1 (for table1 ) and key2 (for table2 ).
Fuzzy matching is a comparison based on similarity of text rather than equality of text.
By default, an inner join is performed, however an optional joinKind may be included to specify the type of
join. Options include:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

An optional set of joinOptions may be included to specify how to compare the key columns. Options include:
ConcurrentRequests : A number between 1 and 8 that specifies the number of parallel threads to use for fuzzy
matching. The default value is 1.
Culture : Allows matching records based on culture-specific rules. It can be any valid culture name. For
example, a Culture option of "ja-JP" matches records based on the Japanese culture. The default value is "",
which matches based on the Invariant English culture.
IgnoreCase : A logical (true/false) value that allows case-insensitive key matching. For example, when true,
"Grapes" is matched with "grapes". The default value is true.
IgnoreSpace : A logical (true/false) value that allows combining of text parts in order to find matches. For
example, when true, "Gra pes" is matched with "Grapes". The default value is true.
NumberOfMatches : A whole number that specifies the maximum number of matching rows that can be
returned for every input row. For example, a value of 1 will return at most one matching row for each input
row. If this option is not provided, all matching rows are returned.
SimilarityColumnName : A name for the column that shows the similarity between an input value and the
representative value for that input. The default value is null, in which case a new column for similarities will
not be added.
Threshold : A number between 0.00 and 1.00 that specifies the similarity score at which two values will be
matched. For example, "Grapes" and "Graes" (missing "p") are matched only if this option is set to less than
0.90. A threshold of 1.00 is the same as specifying an exact match criteria. The default value is 0.80.
TransformationTable : A table that allows matching records based on custom value mappings. It should
contain "From" and "To" columns. For example, "Grapes" is matched with "Raisins" if a transformation table is
provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that
the transformation will be applied to all occurrences of the text in the transformation table. With the above
transformation table, "Grapes are sweet" will also be matched with "Raisins are sweet".

Example 1
Left inner fuzzy join of two tables based on [FirstName]
Usage

[Link](
[Link](
{
[CustomerID = 1, FirstName1 = "Bob", Phone = "555-1234"],
[CustomerID = 2, FirstName1 = "Robert", Phone = "555-4567"]
},
type table [CustomerID = nullable number, FirstName1 = nullable text, Phone = nullable text]
),
{"FirstName1"},
[Link](
{
[CustomerStateID = 1, FirstName2 = "Bob", State = "TX"],
[CustomerStateID = 2, FirstName2 = "bOB", State = "CA"]
},
type table [CustomerStateID = nullable number, FirstName2 = nullable text, State = nullable text]
),
{"FirstName2"},
[Link],
[IgnoreCase = true, IgnoreSpace = false]
)

Output

[Link]({
[
CustomerID = 1,
FirstName1 = "Bob",
Phone = "555-1234",
CustomerStateID = 1,
FirstName2 = "Bob",
State = "TX"
],
[
CustomerID = 1,
FirstName1 = "Bob",
Phone = "555-1234",
CustomerStateID = 2,
FirstName2 = "bOB",
State = "CA"
],
[
CustomerID = 2,
FirstName1 = "Robert",
Phone = "555-4567",
CustomerStateID = null,
FirstName2 = null,
State = null
]
})
[Link]
9/13/2022 • 3 minutes to read

Syntax
[Link](table1 as table, key1 as any, table2 as table, key2 as any, newColumnName
as text, optional joinKind as nullable number, optional joinOptions as nullable record) as table

About
Joins the rows of table1 with the rows of table2 based on a fuzzy matching of the values of the key columns
selected by key1 (for table1 ) and key2 (for table2 ). The results are returned in a new column named
newColumnName .

Fuzzy matching is a comparison based on similarity of text rather than equality of text.
The optional joinKind specifies the kind of join to perform. By default, a left outer join is performed if a
joinKind is not specified. Options include:

[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

An optional set of joinOptions may be included to specify how to compare the key columns. Options include:
ConcurrentRequests : A number between 1 and 8 that specifies the number of parallel threads to use for fuzzy
matching. The default value is 1.
Culture : Allows matching records based on culture-specific rules. It can be any valid culture name. For
example, a Culture option of "ja-JP" matches records based on the Japanese culture. The default value is "",
which matches based on the Invariant English culture.
IgnoreCase : A logical (true/false) value that allows case-insensitive key matching. For example, when true,
"Grapes" is matched with "grapes". The default value is true.
IgnoreSpace : A logical (true/false) value that allows combining of text parts in order to find matches. For
example, when true, "Gra pes" is matched with "Grapes". The default value is true.
NumberOfMatches : A whole number that specifies the maximum number of matching rows that can be
returned for every input row. For example, a value of 1 will return at most one matching row for each input
row. If this option is not provided, all matching rows are returned.
SimilarityColumnName : A name for the column that shows the similarity between an input value and the
representative value for that input. The default value is null, in which case a new column for similarities will
not be added.
Threshold : A number between 0.00 and 1.00 that specifies the similarity score at which two values will be
matched. For example, "Grapes" and "Graes" (missing "p") are matched only if this option is set to less than
0.90. A threshold of 1.00 is the same as specifying an exact match criteria. The default value is 0.80.
TransformationTable : A table that allows matching records based on custom value mappings. It should
contain "From" and "To" columns. For example, "Grapes" is matched with "Raisins" if a transformation table is
provided with the "From" column containing "Grapes" and the "To" column containing "Raisins". Note that
the transformation will be applied to all occurrences of the text in the transformation table. With the above
transformation table, "Grapes are sweet" will also be matched with "Raisins are sweet".

Example 1
Left inner fuzzy join of two tables based on [FirstName]
Usage

[Link](
[Link](
{
[CustomerID = 1, FirstName1 = "Bob", Phone = "555-1234"],
[CustomerID = 2, FirstName1 = "Robert", Phone = "555-4567"]
},
type table [CustomerID = nullable number, FirstName1 = nullable text, Phone = nullable text]
),
{"FirstName1"},
[Link](
{
[CustomerStateID = 1, FirstName2 = "Bob", State = "TX"],
[CustomerStateID = 2, FirstName2 = "bOB", State = "CA"]
},
type table [CustomerStateID = nullable number, FirstName2 = nullable text, State = nullable text]
),
{"FirstName2"},
"NestedTable",
[Link],
[IgnoreCase = true, IgnoreSpace = false]
)

Output

[Link]({
[
CustomerID = 1,
FirstName1 = "Bob",
Phone = "555-1234",
NestedTable = [Link]({
[
CustomerStateID = 1,
FirstName2 = "Bob",
State = "TX"
],
[
CustomerStateID = 2,
FirstName2 = "bOB",
State = "CA"
]
})
],
[
CustomerID = 2,
FirstName1 = "Robert",
Phone = "555-4567",
NestedTable = [Link]({})
]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, key as any, aggregatedColumns as list, optional groupKind as
nullable number, optional comparer as nullable function) as table

About
Groups the rows of table by the key columns defined by key . The key can either be a single column name,
or a list of column names. For each group, a record is constructed containing the key columns (and their values),
along with any aggregated columns specified by aggregatedColumns . Optionally, groupKind and comparer may
also be specified.
If the data is already sorted by the key columns, then a groupKind of [Link] can be provided. This may
improve the performance of grouping in certain cases, since all the rows with a given set of key values are
assumed to be contiguous.
When passing a comparer , note that if it treats differing keys as equal, a row may be placed in a group whose
keys differ from its own.
This function does not guarantee the ordering of the rows it returns.

Example 1
Group the table adding an aggregate column [total] which contains the sum of prices ("each [Link]([price])").
Usage

[Link](
[Link]({
[CustomerID = 1, price = 20],
[CustomerID = 2, price = 10],
[CustomerID = 2, price = 20],
[CustomerID = 1, price = 10],
[CustomerID = 3, price = 20],
[CustomerID = 3, price = 5]
}),
"CustomerID",
{"total", each [Link]([price])}
)

Output

[Link](
{
[CustomerID = 1, total = 30],
[CustomerID = 2, total = 30],
[CustomerID = 3, total = 25]
},
{"CustomerID", "total"}
)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columns as any) as logical

About
indicates whether the table contains the specified column(s), columns . Returns true if the table contains the
column(s), false otherwise.

Example 1
Determine if the table has the column [Name].
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"Name"
)

Output
true

Example 2
Find if the table has the column [Name] and [PhoneNumber].
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
{"Name", "PhoneNumber"}
)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, offset as number, rows as list) as table

About
Returns a table with the list of rows, rows , inserted into the table at the given position, offset . Each column
in the row to insert must match the column types of the table.

Example 1
Insert the row into the table at position 1.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}),
1,
{[CustomerID = 3, Name = "Paul", Phone = "543-7890"]}
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})

Example 2
Insert two rows into the table at position 1.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
1,
{
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}
)

Output
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional comparisonCriteria as any) as logical

About
Indicates whether the table contains only distinct rows (no duplicates). Returns true if the rows are distinct,
false otherwise. An optional parameter, comparisonCriteria , specifies which columns of the table are tested
for duplication. If comparisonCriteria is not specified, all columns are tested.

Example 1
Determine if the table is distinct.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
)

Output
true

Example 2
Determine if the table is distinct in column.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 5, Name = "Bob", Phone = "232-1550"]
}),
"Name"
)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as logical

About
Indicates whether the table contains any rows. Returns true if there are no rows (i.e. the table is empty),
false otherwise.

Example 1
Determine if the table is empty.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
)

Output
false

Example 2
Determine if the table ({}) is empty.
Usage

[Link]([Link]({}))

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table1 as table, key1 as any, table2 as table, key2 as any, optional joinKind as
nullable number, optional joinAlgorithm as nullable number, optional keyEqualityComparers as
nullable list) as table

About
Joins the rows of table1 with the rows of table2 based on the equality of the values of the key columns
selected by key1 (for table1 ) and key2 (for table2 ).
By default, an inner join is performed, however an optional joinKind may be included to specify the type of
join. Options include:
[Link]
[Link]
[Link]
[Link]
[Link]
[Link]

An optional set of keyEqualityComparers may be included to specify how to compare the key columns. This
feature is currently intended for internal use only.

Example 1
Join two tables using a single key column.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"CustomerID",
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25]
}),
"CustomerID"
)
Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 1, Item = "Fishing rod", Price = 100],
[CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 2, Item = "1 lb. worms", Price = 5],
[CustomerID = 2, Name = "Jim", Phone = "987-6543", OrderID = 3, Item = "Fishing net", Price = 25],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", OrderID = 4, Item = "Fish tazer", Price = 200],
[CustomerID = 3, Name = "Paul", Phone = "543-7890", OrderID = 5, Item = "Bandaids", Price = 2],
[CustomerID = 1, Name = "Bob", Phone = "123-4567", OrderID = 6, Item = "Tackle box", Price = 20]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as list

About
Returns the keys of the specified table.

Example 1
Get the list of keys for a table.
Usage

let
table = [Link]({
[Id = 1, Name = "Hello There"],
[Id = 2, Name = "Good Bye"]
}),
tableWithKeys = [Link](table, {"Id"}, true),
keys = [Link](tableWithKeys)
in
keys

Output
{[Columns = {"Id"}, Primary = true]}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional default as any) as any

About
Returns the last row of the table or an optional default value, default , if the table is empty.

Example 1
Find the last row of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
)

Output
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]

Example 2
Find the last row of the table ({}) or return [a = 0, b = 0] if empty.
Usage

[Link]([Link]({}), [a = 0, b = 0])

Output
[a = 0, b = 0]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, countOrCondition as any) as table

About
Returns the last row(s) from the table, table , depending on the value of countOrCondition :
If countOrCondition is a number, that many rows will be returned starting from position (end -
countOrCondition ).
If countOrCondition is a condition, the rows that meet the condition will be returned in ascending position
until a row does not meet the condition.

Example 1
Find the last two rows of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}),
2
)

Output

[Link]({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Example 2
Find the last rows where [a] > 0 in the table.
Usage
[Link](
[Link]({
[a = -1, b = -2],
[a = 3, b = 4],
[a = 5, b = 6]
}),
each _ [a] > 0

Output

[Link]({
[a = 3, b = 4],
[a = 5, b = 6]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, condition as function) as logical

About
Indicates whether all the rows in the table match the given condition . Returns true if all of the rows match,
false otherwise.

Example 1
Determine whether all of the row values in column [a] are even in the table.
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 6, b = 8]
}),
each [Link]([a], 2) = 0
)

Output
true

Example 2
Find if all of the row values are [a = 1, b = 2], in the table ({[a = 1, b = 2], [a = 3, b = 4]}) .
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = -3, b = 4]
}),
each _ = [a = 1, b = 2]
)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, condition as function) as logical

About
Indicates whether any the rows in the table match the given condition . Returns true if any of the rows
match, false otherwise.

Example 1
Determine whether any of the row values in column [a] are even in the table
({[a = 2, b = 4], [a = 6, b = 8]}) .

Usage

[Link](
[Link]({
[a = 1, b = 4],
[a = 3, b = 8]
}),
each [Link]([a], 2) = 0
)

Output
false

Example 2
Determine whether any of the row values are [a = 1, b = 2], in the table ({[a = 1, b = 2], [a = 3, b = 4]}) .
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = -3, b = 4]
}),
each _ = [a = 1, b = 2]
)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, comparisonCriteria as any, optional default as any) as any

About
Returns the largest row in the table , given the comparisonCriteria . If the table is empty, the optional default
value is returned.

Example 1
Find the row with the largest value in column [a] in the table ({[a = 2, b = 4], [a = 6, b = 8]}) .
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 6, b = 8]
}),
"a"
)

Output
[a = 6, b = 8]

Example 2
Find the row with the largest value in column [a] in the table ({}) . Return -1 if empty.
Usage

[Link](#table({"a"}, {}), "a", -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, comparisonCriteria as any, countOrCondition as any) as table

About
Returns the largest row(s) in the table , given the comparisonCriteria . After the rows are sorted, the
countOrCondition parameter must be specified to further filter the result. Note the sorting algorithm cannot
guarantee a fixed sorted result. The countOrCondition parameter can take multiple forms:
If a number is specified, a list of up to countOrCondition items in ascending order is returned.
If a condition is specified, a list of items that initially meet the condition is returned. Once an item fails the
condition, no further items are considered.

Example 1
Find the row with the largest value in column [a] with the condition [a] > 0, in the table. The rows are sorted
before the filter is applied.
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 0, b = 0],
[a = 6, b = 2]
}),
"a",
each [a] > 0
)

Output

[Link]({
[a = 6, b = 2],
[a = 2, b = 4]
})

Example 2
Find the row with the largest value in column [a] with the condition [b] > 0, in the table. The rows are sorted
before the filter is applied.
Usage
[Link](
[Link]({
[a = 2, b = 4],
[a = 8, b = 0],
[a = 6, b = 2]
}),
"a",
each [b] > 0
)

Output
[Link]({})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, comparisonCriteria as any, optional default as any) as any

About
Returns the smallest row in the table , given the comparisonCriteria . If the table is empty, the optional default
value is returned.

Example 1
Find the row with the smallest value in column [a] in the table.
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 6, b = 8]
}),
"a"
)

Output
[a = 2, b = 4]

Example 2
Find the row with the smallest value in column [a] in the table. Return -1 if empty.
Usage

[Link](#table({"a"}, {}), "a", -1)

Output
-1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, comparisonCriteria as any, countOrCondition as any) as table

About
Returns the smallest row(s) in the table , given the comparisonCriteria . After the rows are sorted, the
countOrCondition parameter must be specified to further filter the result. Note the sorting algorithm cannot
guarantee a fixed sorted result. The countOrCondition parameter can take multiple forms:
If a number is specified, a list of up to countOrCondition items in ascending order is returned.
If a condition is specified, a list of items that initially meet the condition is returned. Once an item fails the
condition, no further items are considered.

Example 1
Find the row with the smallest value in column [a] with the condition [a] < 3, in the table. The rows are sorted
before the filter is applied.
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 0, b = 0],
[a = 6, b = 4]
}),
"a",
each [a] < 3
)

Output

[Link]({
[a = 0, b = 0],
[a = 2, b = 4]
})

Example 2
Find the row with the smallest value in column [a] with the condition [b] < 0, in the table. The rows are sorted
before the filter is applied.
Usage
[Link](
[Link]({
[a = 2, b = 4],
[a = 8, b = 0],
[a = 6, b = 2]
}),
"a",
each [b] < 0
)

Output
[Link]({})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table1 as table, key1 as any, table2 as any, key2 as any, newColumnName as
text, optional joinKind as nullable number, optional keyEqualityComparers as nullable list) as
table

About
Joins the rows of table1 with the rows of table2 based on the equality of the values of the key columns
selected by key1 (for table1 ) and key2 (for table2 ). The results are entered into the column named
newColumnName .

The optional joinKind specifies the kind of join to perform. By default, a left outer join is performed if a
joinKind is not specified.

An optional set of keyEqualityComparers may be included to specify how to compare the key columns. This
keyEqualityComparers feature is currently intended for internal use only.

Example 1
Join two tables using a single key column.
Usage

[Link](
[Link]({
[CustomerToCall = 1],
[CustomerToCall = 3]
}),
{"CustomerToCall"},
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
{"CustomerID"},
"CustomerDetails"
)

Output

[Link]({
[CustomerToCall = 1, CustomerDetails = [Link]({[CustomerID = 1, Name = "Bob", Phone = "123-
4567"]})],
[CustomerToCall = 3, CustomerDetails = [Link]({[CustomerID = 3, Name = "Paul", Phone = "543-
7890"]})]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, column as text, groups as number, hash as function) as list

About
Partitions the table into a list of groups number of tables, based on the value of the column and a hash
function. The hash function is applied to the value of the column row to obtain a hash value for the row. The
hash value modulo groups determines in which of the returned tables the row will be placed.
table : The table to partition.
column : The column to hash to determine which returned table the row is in.
groups : The number of tables the input table will be partitioned into.
hash : The function applied to obtain a hash value.

Example 1
Partition the table ({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]}) into 2 tables on column
[a], using the value of the columns as the hash function.
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 1, b = 4],
[a = 2, b = 4],
[a = 1, b = 4]
}),
"a",
2,
each _
)

Output

{
[Link]({
[a = 2, b = 4],
[a = 2, b = 4]
}),
[Link]({
[a = 1, b = 4],
[a = 1, b = 4]
})
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as table

About
Returns information about how a table is partitioned. A table is returned where each column is a partition
column in the original table, and each row corresponds to a partition in the original table.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, pivotValues as list, attributeColumn as text, valueColumn as text,
optional aggregationFunction as nullable function) as table

About
Given a pair of columns representing attribute-value pairs, rotates the data in the attribute column into a
column headings.

Example 1
Take the values "a", "b", and "c" in the attribute column of table
({ [ key = "x", attribute = "a", value = 1 ], [ key = "x", attribute = "c", value = 3 ], [ key = "y",
attribute = "a", value = 2 ], [ key = "y", attribute = "b", value = 4 ] })
and pivot them into their own column.
Usage

[Link](
[Link]({
[key = "x", attribute = "a", value = 1],
[key = "x", attribute = "c", value = 3],
[key = "y", attribute = "a", value = 2],
[key = "y", attribute = "b", value = 4]
}),
{"a", "b", "c"},
"attribute",
"value"
)

Output

[Link]({
[key = "x", a = 1, b = null, c = 3],
[key = "y", a = 2, b = 4, c = null]
})

Example 2
Take the values "a", "b", and "c" in the attribute column of table
({ [ key = "x", attribute = "a", value = 1 ], [ key = "x", attribute = "c", value = 3 ], [ key = "x",
attribute = "c", value = 5 ], [ key = "y", attribute = "a", value = 2 ], [ key = "y", attribute = "b", value
= 4 ] })
and pivot them into their own column. The attribute "c" for key "x" has multiple values associated with it, so use
the function [Link] to resolve the conflict.
Usage
[Link](
[Link]({
[key = "x", attribute = "a", value = 1],
[key = "x", attribute = "c", value = 3],
[key = "x", attribute = "c", value = 5],
[key = "y", attribute = "a", value = 2],
[key = "y", attribute = "b", value = 4]
}),
{"a", "b", "c"},
"attribute",
"value",
[Link]
)

Output

[Link]({
[key = "x", a = 1, b = null, c = 5],
[key = "y", a = 2, b = 4, c = null]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, row as record, optional occurrence as any, optional
equationCriteria as any) as any

About
Returns the row position of the first occurrence of the row in the table specified. Returns -1 if no occurrence is
found.
table : The input table.
row : The row in the table to find the position of.
occurrence : [Optional] Specifies which occurrences of the row to return.
equationCriteria : [Optional] Controls the comparison between the table rows.

Example 1
Find the position of the first occurrence of [a = 2, b = 4] in the table
({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]}) .
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 1, b = 4],
[a = 2, b = 4],
[a = 1, b = 4]
}),
[a = 2, b = 4]
)

Output
0

Example 2
Find the position of the second occurrence of [a = 2, b = 4] in the table
({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]}) .

Usage
[Link](
[Link]({
[a = 2, b = 4],
[a = 1, b = 4],
[a = 2, b = 4],
[a = 1, b = 4]
}),
[a = 2, b = 4],
1
)

Output
2

Example 3
Find the position of all the occurrences of [a = 2, b = 4] in the table
({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]}) .
Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 1, b = 4],
[a = 2, b = 4],
[a = 1, b = 4]
}),
[a = 2, b = 4],
[Link]
)

Output
{0, 2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, rows as list, optional occurrence as nullable number,
optional equationCriteria as any) as any

About
Returns the row(s) position(s) from the table of the first occurrence of the list of rows . Returns -1 if no
occurrence is found.
table : The input table.
rows : The list of rows in the table to find the positions of.
occurrence : [Optional] Specifies which occurrences of the row to return.
`equationCriteria: [Optional] Controls the comparison between the table rows.

Example 1
Find the position of the first occurrence of [a = 2, b = 4] or [a = 6, b = 8] in the table
({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]}) .

Usage

[Link](
[Link]({
[a = 2, b = 4],
[a = 1, b = 4],
[a = 2, b = 4],
[a = 1, b = 4]
}),
{
[a = 2, b = 4],
[a = 6, b = 8]
}
)

Output
0

Example 2
Find the position of all the occurrences of [a = 2, b = 4] or [a = 6, b = 8] in the table
({[a = 2, b = 4], [a = 6, b = 8], [a = 2, b = 4], [a = 1, b = 4]} .

Usage
[Link](
[Link]({
[a = 2, b = 4],
[a = 6, b = 8],
[a = 2, b = 4],
[a = 1, b = 4]
}),
{
[a = 2, b = 4],
[a = 6, b = 8]
},
[Link]
)

Output
{0, 1, 2}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, prefix as text) as table

About
Returns a table where all the column names from the table provided are prefixed with the given text, prefix ,
plus a period in the form prefix .ColumnName .

Example 1
Prefix the columns with "MyTable" in the table.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
"MyTable"
)

Output
[Link]({[[Link] = 1, [Link] = "Bob", [Link] = "123-4567"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional additionalAggregates as nullable list) as table

About
Returns a profile for the columns in table .
The following information is returned for each column (when applicable):
minimum
maximum
average
standard deviation
count
null count
distinct count
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional options as nullable record) as table

About
Promotes the first row of values as the new column headers (i.e. column names). By default, only text or number
values are promoted to headers. Valid options:
PromoteAllScalars : If set to true , all the scalar values in the first row are promoted to headers using the
Culture , if specified (or current document locale). For values that cannot be converted to text, a default
column name will be used.
Culture : A culture name specifying the culture for the data.

Example 1
Promote the first row of values in the table.
Usage

[Link](
[Link]({
[Column1 = "CustomerID", Column2 = "Name", Column3 = #date(1980, 1, 1)],
[Column1 = 1, Column2 = "Bob", Column3 = #date(1980, 1, 1)]
})
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Column3 = #date(1980, 1, 1)]})

Example 2
Promote all the scalars in the first row of the table to headers.
Usage

[Link](
[Link]({
[Rank = 1, Name = "Name", Date = #date(1980, 1, 1)],
[Rank = 1, Name = "Bob", Date = #date(1980, 1, 1)]}
),
[PromoteAllScalars = true, Culture = "en-US"]
)

Output
[Link]({[1 = 1, Name = "Bob", #"1/1/1980" = #date(1980, 1, 1)]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, offset as number, optional count as nullable number) as table

About
Returns the rows from the table starting at the specified offset . An optional parameter, count , specifies how
many rows to return. By default, all the rows after the offset are returned.

Example 1
Return all the rows starting at offset 1 in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1
)

Output

[Link]({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 2
Return one row starting at offset 1 in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1,
1
)
Output
[Link]({[CustomerID = 2, Name = "Jim", Phone = "987-6543"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columns as any, optional missingField as nullable number) as
table

About
Removes the specified columns from the table provided. If the column doesn't exist, an exception is thrown
unless the optional parameter missingField specifies an alternative (eg. [Link] or
[Link] ).

Example 1
Remove column [Phone] from the table.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
"Phone"

Output
[Link]({[CustomerID = 1, Name = "Bob"]})

Example 2
Remove column [Address] from the table. Throws an error if it doesn't exist.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
"Address"
)

Output
[[Link]] The field 'Address' of the record was not found.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional countOrCondition as any) as table

About
Returns a table that does not contain the first specified number of rows, countOrCondition , of the table table .
The number of rows removed depends on the optional parameter countOrCondition .
If countOrCondition is omitted only the first row is removed.
If countOrCondition is a number, that many rows (starting at the top) will be removed.
If countOrCondition is a condition, the rows that meet the condition will be removed until a row does not
meet the condition.

Example 1
Remove the first row of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1
)

Output

[Link]({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 2
Remove the first two rows of the table.
Usage
[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
2
)

Output

[Link]({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 3
Remove the first rows where [CustomerID] <=2 of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"] ,
[CustomerID = 3, Name = "Paul", Phone = "543-7890"] ,
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
each [CustomerID] <= 2
)

Output

[Link]({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional countOrCondition as any) as table

About
Returns a table that does not contain the last countOrCondition rows of the table table . The number of rows
removed depends on the optional parameter countOrCondition .

If countOrCondition is omitted only the last row is removed.


If countOrCondition is a number, that many rows (starting at the bottom) will be removed.
If countOrCondition is a condition, the rows that meet the condition will be removed until a row does not
meet the condition.

Example 1
Remove the last row of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})

Example 2
Remove the last rows where [CustomerID] > 2 of the table.
Usage
[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
each [CustomerID] >= 2
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, rows as list, optional equationCriteria as any) as
table

About
Removes all occurrences of the specified rows from the table . An optional parameter equationCriteria may
be specified to control the comparison between the rows of the table.

Example 1
Remove any rows where [a = 1] from the table ({[a = 1, b = 2], [a = 3, b = 4], [a = 1, b = 6]}) .
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4],
[a = 1, b = 6]
}),
{[a = 1]},
"a"
)

Output
[Link]({[a = 3, b = 4]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, offset as number, optional count as nullable number) as table

About
Removes count of rows from the beginning of the table , starting at the offset specified. A default count of 1
is used if the count parameter isn't provided.

Example 1
Remove the first row from the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
0
)

Output

[Link]({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 2
Remove the row at position 1 from the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1
)
Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 3
Remove two rows starting at position 1 from the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1,
2
)

Output

[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional columns as nullable list) as table

About
Returns a table with the rows removed from the input table that contain an error in at least one of the cells. If a
columns list is specified, then only the cells in the specified columns are inspected for errors.

Example 1
Remove error value from first row.
Usage

[Link](
[Link]({
[Column1 = ...],
[Column1 = 2],
[Column1 = 3]
})
)

Output

[Link]({
[Column1 = 2],
[Column1 = 3]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, renames as list, optional missingField as nullable number)
as table

About
Performs the given renames to the columns in table table . A replacement operation renames consists of a list
of two values, the old column name and new column name, provided in a list. If the column doesn't exist, an
exception is thrown unless the optional parameter missingField specifies an alternative (eg.
[Link] or [Link] ).

Example 1
Replace the column name "CustomerNum" with "CustomerID" in the table.
Usage

[Link](
[Link]({[CustomerNum = 1, Name = "Bob", Phone = "123-4567"]}),
{"CustomerNum", "CustomerID"}
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})

Example 2
Replace the column name "CustomerNum" with "CustomerID" and "PhoneNum" with "Phone" in the table.
Usage

[Link](
[Link]({[CustomerNum = 1, Name = "Bob", PhoneNum = "123-4567"]}),
{
{"CustomerNum", "CustomerID"},
{"PhoneNum", "Phone"}
}
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})

Example 3
Replace the column name "NewCol" with "NewColumn" in the table, and ignore if the column doesn't exist.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
{"NewCol", "NewColumn"},
[Link]
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columnOrder as list, optional missingField as nullable
number) as table

About
Returns a table from the input table , with the columns in the order specified by columnOrder . Columns that are
not specified in the list will not be reordered. If the column doesn't exist, an exception is thrown unless the
optional parameter missingField specifies an alternative (eg. [Link] or [Link] ).

Example 1
Switch the order of the columns [Phone] and [Name] in the table.
Usage

[Link](
[Link]({[CustomerID = 1, Phone = "123-4567", Name = "Bob"]}),
{"Name", "Phone"}
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})

Example 2
Switch the order of the columns [Phone] and [Address] or use "[Link]" in the table. It doesn't
change the table because column [Address] doesn't exist.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
{"Phone", "Address"},
[Link]
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, count as number) as table

About
Returns a table with the rows from the input table repeated the specified count times.

Example 1
Repeat the rows in the table two times.
Usage

[Link](
[Link]({
[a = 1, b = "hello"],
[a = 3, b = "world"]
}),
2

Output

[Link]({
[a = 1, b = "hello"],
[a = 3, b = "world"],
[a = 1, b = "hello"],
[a = 3, b = "world"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, errorReplacement as list) as table

About
Replaces the error values in the specified columns of the table with the new values in the errorReplacement
list. The format of the list is {{column1, value1}, ...}. There may only be one replacement value per column,
specifying the column more than once will result in an error.

Example 1
Replace the error value with the text "world" in the table.
Usage

[Link](
[Link]({{1, "hello"}, {3, ...}}, {"A", "B"}),
{"B", "world"}
)

Output

[Link]({
[A = 1, B = "hello"],
[A = 3, B = "world"]
})

Example 2
Replace the error value in column A with the text "hello" and in column B with the text "world" in the table.
Usage

[Link](
[Link]({{..., ...}, {1, 2}}, {"A", "B"}),
{{"A", "hello"}, {"B", "world"}}
)

Output

[Link]({
[A = "hello", B = "world"],
[A = 1, B = 2]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, keys as list) as table

About
Replaces the keys of the specified table.

Example 1
Replace the existing keys of a table.
Usage

let
table = [Link]({
[Id = 1, Name = "Hello There"],
[Id = 2, Name = "Good Bye"]
}),
tableWithKeys = [Link](table, {"Id"}, true),
resultTable = [Link](tableWithKeys, {[Columns = {"Id"}, Primary = false]})
in
resultTable

Output

[Link]({
[Id = 1, Name = "Hello There"],
[Id = 2, Name = "Good Bye"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, replacements as list, optional equationCriteria as
any) as table

About
Replaces all the specified rows in the table with the provided ones. The rows to replace and the replacements
are specified in replacements , using {old, new} formatting. An optional equationCriteria parameter may be
specified to control comparison between the rows of the table.

Example 1
Replace the rows [a = 1, b = 2] and [a = 2, b = 3] with [a = -1, b = -2],[a = -2, b = -3] in the table.
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 2, b = 3],
[a = 3, b = 4],
[a = 1, b = 2]
}),
{
{[a = 1, b = 2], [a = -1, b = -2]},
{[a = 2, b = 3], [a = -2, b = -3]}
}
)

Output

[Link]({
[a = -1, b = -2],
[a = -2, b = -3],
[a = 3, b = 4],
[a = -1, b = -2]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, identity as text) as any

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, offset as number, count as number, rows as list) as table

About
Replaces a specified number of rows, count , in the input table with the specified rows , beginning after the
offset . The rows parameter is a list of records.

table : The table where the replacement is performed.


offset : The number of rows to skip before making the replacement.
count : The number of rows to replace.
rows : The list of row records to insert into the table at the location specified by the offset .

Example 1
Starting at position 1, replace 3 rows.
Usage

[Link](
[Link]({
[Column1 = 1],
[Column1 = 2],
[Column1 = 3],
[Column1 = 4],
[Column1 = 5]
}),
1,
3,
{[Column1 = 6], [Column1 = 7]}
)

Output

[Link]({
[Column1 = 1],
[Column1 = 6],
[Column1 = 7],
[Column1 = 5]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, oldValue as any, newValue as any, replacer as function,
columnsToSearch as list) as table

About
Replaces oldValue with newValue in the specified columns of the table .

Example 1
Replace the text "goodbye" with the text "world" in the table.
Usage

[Link](
[Link]({
[a = 1, b = "hello"],
[a = 3, b = "goodbye"]
}),
"goodbye",
"world",
[Link],
{"b"}
)

Output

[Link]({
[a = 1, b = "hello"],
[a = 3, b = "world"]
})

Example 2
Replace the text "ur" with the text "or" in the table.
Usage

[Link](
[Link]({
[a = 1, b = "hello"],
[a = 3, b = "wurld"]
}),
"ur",
"or",
[Link],
{"b"}
)
Output

[Link]({
[a = 1, b = "hello"],
[a = 3, b = "world"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as table

About
Returns a table with the rows from the input table in reverse order.

Example 1
Reverse the rows in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
)

Output

[Link]({
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as number

About
Returns the number of rows in the table .

Example 1
Find the number of rows in the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
)

Output
3
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as table

About
Returns a table describing the columns of table .
Each row in the table describes the properties of a column of table :

C O L UM N N A M E DESC RIP T IO N

Name The name of the column.

Position The 0-based position of the column in table .

TypeName The name of the type of the column.

Kind The kind of the type of the column.

IsNullable Whether the column can contain null values.

NumericPrecisionBase The numeric base (for example, base-2 or base-10) of the


NumericPrecision and NumericScale fields.

NumericPrecision The precision of a numeric column in the base specified by


NumericPrecisionBase . This is the maximum number of
digits that can be represented by a value of this type
(including fractional digits).

NumericScale The scale of a numeric column in the base specified by


NumericPrecisionBase . This is the number of digits in the
fractional part of a value of this type. A value of 0 indicates
a fixed scale with no fractional digits. A value of null
indicates the scale is not known (either because it is floating
or not defined).

DateTimePrecision The maximum number of fractional digits supported in the


seconds portion of a date or time value.

MaxLength The maximum number of characters permitted in a text


column, or the maximum number of bytes permitted in a
binary column.

IsVariableLength Indicates whether this column can vary in length (up to


MaxLength ) or if it is of fixed size.
C O L UM N N A M E DESC RIP T IO N

NativeTypeName The name of the type of the column in the native type
system of the source (for example, nvarchar for SQL
Server).

NativeDefaultExpression The default expression for a value of this column in the


native expression language of the source (for example, 42
or newid() for SQL Server).

Description The description of the column.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, columns as any, optional missingField as nullable number) as
table

About
Returns the table with only the specified columns .
table : The provided table.
columns : The list of columns from the table table to return. Columns in the returned table are in the order
listed in columns .
missingField : (Optional) What to do if the column does not exist. Example: [Link] or
[Link] .

Example 1
Only include column [Name].
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
"Name"
)

Output

[Link]({
[Name = "Bob"],
[Name = "Jim"],
[Name = "Paul"],
[Name = "Ringo"]
})

Example 2
Only include columns [CustomerID] and [Name].
Usage
[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
{"CustomerID", "Name"}
)

Output
[Link]({[CustomerID = 1, Name = "Bob"]})

Example 3
If the included column does not exist, the default result is an error.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
"NewColumn"
)

Output
[[Link]] The field 'NewColumn' of the record wasn't found.

Example 4
If the included column does not exist, option [Link] creates a column of null values.
Usage

[Link](
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
{"CustomerID", "NewColumn"},
[Link]
)

Output
[Link]({[CustomerID = 1, NewColumn = null]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, condition as function) as table

About
Returns a table of rows from the table , that matches the selection condition .

Example 1
Select the rows in the table where the values in [CustomerID] column are greater than 2.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
each [CustomerID] > 2
)

Output

[Link]({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 2
Select the rows in the table where the names do not contain a "B".
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
each not [Link]([Name], "B")
)

Output
[Link]({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional columns as nullable list) as table

About
Returns a table with only those rows of the input table that contain an error in at least one of the cells. If a
columns list is specified, then only the cells in the specified columns are inspected for errors.

Example 1
Select names of customers with errors in their rows.
Usage

[Link](
[Link]({
[CustomerID = ..., Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})
)[Name]

Output
{"Bob"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as record

About
Returns the single row in the one row table . If the table has more than one row, an exception is thrown.

Example 1
Return the single row in the table.
Usage

[Link]([Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}))

Output
[CustomerID = 1, Name = "Bob", Phone = "123-4567"]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional countOrCondition as any) as table

About
Returns a table that does not contain the first specified number of rows, countOrCondition , of the table table .
The number of rows skipped depends on the optional parameter countOrCondition .
If countOrCondition is omitted only the first row is skipped.
If countOrCondition is a number, that many rows (starting at the top) will be skipped.
If countOrCondition is a condition, the rows that meet the condition will be skipped until a row does not meet
the condition.

Example 1
Skip the first row of the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
1
)

Output

[Link]({
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 2
Skip the first two rows of the table.
Usage
[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
}),
2
)

Output

[Link]({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Ringo", Phone = "232-1550"]
})

Example 3
Skip the first rows where [Price] > 25 of the table.
Usage

[Link](
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
}),
each [Price] > 25
)

Output

[Link]({
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
})
[Link]
9/13/2022 • 3 minutes to read

Syntax
[Link](table as table, comparisonCriteria as any) as table

About
Sorts the table using the list of one or more column names and optional comparisonCriteria in the form { {
col1, comparisonCriteria }, {col2} }.

Example 1
Sort the table on column "OrderID".
Usage

[Link](
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
}),
{"OrderID"}
)

Output

[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
})

Example 2
Sort the table on column "OrderID" in descending order.
Usage
[Link](
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
}),
{"OrderID", [Link]}
)

Output

[Link]({
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5],
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100]
})

Example 3
Sort the table on column "CustomerID" then "OrderID", with "CustomerID" being in ascending order.
Usage

[Link](
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100.0],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5.0],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25.0],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200.0],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2.0],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20.0],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100.0],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
}),
{
{"CustomerID", [Link]},
"OrderID"
}
)

Output
[Link]({
[OrderID = 1, CustomerID = 1, Item = "Fishing rod", Price = 100],
[OrderID = 2, CustomerID = 1, Item = "1 lb. worms", Price = 5],
[OrderID = 6, CustomerID = 1, Item = "Tackle box", Price = 20],
[OrderID = 3, CustomerID = 2, Item = "Fishing net", Price = 25],
[OrderID = 4, CustomerID = 3, Item = "Fish tazer", Price = 200],
[OrderID = 5, CustomerID = 3, Item = "Bandaids", Price = 2],
[OrderID = 7, CustomerID = 5, Item = "Bait", Price = 3.25],
[OrderID = 8, CustomerID = 5, Item = "Fishing Rod", Price = 100],
[OrderID = 9, CustomerID = 6, Item = "Bait", Price = 3.25]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, pageSize as number) as list

About
Splits table into a list of tables where the first element of the list is a table containing the first pageSize rows
from the source table, the next element of the list is a table containing the next pageSize rows from the source
table, and so on.

Example 1
Split a table of five records into tables with two records each.
Usage

let
Customers = [Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Cristina", Phone = "232-1550"],
[CustomerID = 5, Name = "Anita", Phone = "530-1459"]
})
in
[Link](Customers, 2)

Output

{
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
}),
[Link]({
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Cristina", Phone = "232-1550"]
}),
[Link]({
[CustomerID = 5, Name = "Anita", Phone = "530-1459"]
})
}
[Link]
9/13/2022 • 2 minutes to read

[Link](table as table, count as number) as list

About
Returns a list containing two tables: a table with the first N rows of table (as specified by count ) and a table
containing the remaining rows of table . If the tables of the resulting list are enumerated exactly once and in
order, the function will enumerate table only once.

Example 1
Return the first two rows of the table and the remaining rows of the table.
Usage

[Link](#table({"a", "b", "c"}, {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}), 2)</code>

Output

{
#table({"a", "b", "c"}, {{1, 2, 3}, {4, 5, 6}}),
#table({"a", "b", "c"}, {{7, 8, 9}})
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, sourceColumn as text, splitter as function, optional
columnNamesOrNumber as any, optional default as any, optional extraColumns as any) as table

About
Splits the specified columns into a set of additional columns using the specified splitter function.

Example 1
Split the [Name] column at position of "i" into two columns
Usage

let
Customers = [Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"],
[CustomerID = 4, Name = "Cristina", Phone = "232-1550"]
})
in
[Link](Customers, "Name", [Link]("i"), 2

Output

[Link]({
[CustomerID = 1, Name.1 = "Bob", Name.2 = null, Phone = "123-4567"],
[CustomerID = 2, Name.1 = "J", Name.2 = "m", Phone = "987-6543"],
[CustomerID = 3, Name.1 = "Paul", Name.2 = null, Phone = "543-7890"],
[CustomerID = 4, Name.1 = "Cr", Name.2 = "st", Phone = "232-1550"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as table

About
Prevents any downstream operations from being run against the original source of the data in table .

Example 1
Fetches data from a SQL table in a way that prevents any downstream operations from running as a query on
the SQL server.
Usage

let
Source = [Link]("SomeSQLServer", "MyDb"),
MyTable = Source{[Item="MyTable"]}[Data],
MyLocalTable = [Link](dbo_MyTable)
in
MyLocalTable

Output
table
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as list

About
Creates a list of nested lists from the table, table . Each list item is an inner list that contains the column values.

Example 1
Create a list of the column values from the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"]
})
)

Output
{{1, 2}, {"Bob", "Jim"}, {"123-4567", "987-6543"}}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional combiner as nullable function) as list

About
Converts a table into a list by applying the specified combining function to each row of values in the table.

Example 1
Combine the text of each row with a comma.
Usage

[Link](
[Link]({
{[Link](1), "Bob", "123-4567"},
{[Link](2), "Jim", "987-6543"},
{[Link](3), "Paul", "543-7890"}
}),
[Link](",")
)

Output
{"1,Bob,123-4567", "2,Jim,987-6543", "3,Paul,543-7890"}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as list

About
Converts a table, table , to a list of records.

Example 1
Convert the table to a list of records.
Usage

[Link](
[Link](
{
{1, "Bob", "123-4567"},
{2, "Jim", "987-6543"},
{3, "Paul", "543-7890"}
},
{"CustomerID", "Name", "Phone"}
)
)

Output

{
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table) as list

About
Creates a list of nested lists from the table, table . Each list item is an inner list that contains the row values.

Example 1
Create a list of the row values from the table.
Usage

[Link](
[Link]({
[CustomerID = 1, Name = "Bob", Phone = "123-4567"],
[CustomerID = 2, Name = "Jim", Phone = "987-6543"],
[CustomerID = 3, Name = "Paul", Phone = "543-7890"]
})
)

Output

{
{1, "Bob", "123-4567"},
{2, "Jim", "987-6543"},
{3, "Paul", "543-7890"}
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, nameGenerator as function, optional options as
nullable record) as table

About
Transforms column names by using the given nameGenerator function. Valid options:
MaxLengthspecifies the maximum length of new column names. If the given function results with a longer
column name, the long name will be trimmed.
Comparer is used to control the comparison while generating new column names. Comparers can be used to
provide case-insensitive or culture and locale-aware comparisons.
The following built-in comparers are available in the formula language:
[Link] : Used to perform an exact ordinal comparison
[Link] : Used to perform an exact ordinal case-insensitive comparison
[Link] : Used to perform a culture-aware comparison

Example 1
Remove the #(tab) character from column names
Usage

[Link]([Link]({[#"Col#(tab)umn" = 1]}), [Link])

Output
[Link]({[Column = 1]})

Example 2
Transform column names to generate case-insensitive names of length 6.
Usage

[Link](
[Link]({[ColumnNum = 1, cOlumnnum = 2, coLumnNUM = 3]}),
[Link],
[MaxLength = 6, Comparer = [Link]]
)

Output
[Link]({[Column = 1, cOlum1 = 2, coLum2 = 3]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, transformOperations as list, optional
defaultTransformation as nullable function, optional missingField as nullable number) as table

About
Transforms table by applying each column operation listed in transformOperations (where the format is {
column name, transformation } or { column name, transformation, new column type }). If a
defaultTransformation is specified, it will be applied to all columns not listed in transformOperations . If a
column listed in transformOperations doesn't exist, an exception is thrown unless the optional parameter
missingField specifies an alternative (for example, [Link] or [Link]).

Example 1
Convert the text values in column [A] to number values, and the number values in column [B] to text values.
Usage

[Link](
[Link]({
[A = "1", B = 2],
[A = "5", B = 10]
}),
{
{"A", [Link]},
{"B", [Link]}
}
)

Output

[Link]({
[A = 1, B = "2"],
[A = 5, B = "10"]
})

Example 2
Convert the number values in missing column [X] to text values, ignoring columns which don't exist.
Usage
[Link](
[Link]({
[A = "1", B = 2],
[A = "5", B = 10]
}),
{"X", [Link]},
null,
[Link]
)

Output

[Link]({
[A = "1", B = 2],
[A = "5", B = 10]
})

Example 3
Convert the number values in missing column [X] to text values, defaulting to null on columns which don't exist.
Usage

[Link](
[Link]({
[A = "1", B = 2],
[A = "5", B = 10]
}),
{"X", [Link]},
null,
[Link]
)

Output

[Link]({
[A = "1", B = 2, X = null],
[A = "5", B = 10, X = null]
})

Example 4
Increment the number values in column [B] and convert them to text values, and convert all other columns to
numbers.
Usage

[Link](
[Link]({
[A = "1", B = 2],
[A = "5", B = 10]
}),
{"B", each [Link](_ + 1), type text},
[Link]
)

Output
[Link]({
[A = 1, B = "3"],
[A = 5, B = "11"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, typeTransformations as list, optional culture as
nullable text) as table

About
Returns a table from the input table by applying the transform operation to the columns specified in the
parameter typeTransformations (where format is { column name, type name}), using the specified culture in the
optional parameter culture (for example, "en-US"). If the column doesn't exist, an exception is thrown.

Example 1
Transform the number values in column [a] to text values from the table ({[a = 1, b = 2], [a = 3, b = 4]}) .
Usage

[Link](
[Link]({
[a = 1, b = 2],
[a = 3, b = 4]
}),
{"a", type text},
"en-US"
)

Output

[Link]({
[a = "1", b = 2],
[a = "3", b = 4]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, transform as function) as list

About
Creates a list by applying the transform operation to each row in table .

Example 1
Transform the rows of a table into a list of numbers.
Usage

[Link](
[Link]({
[a = 1],
[a = 2],
[a = 3],
[a = 4],
[a = 5]
}),
each [a]
)

Output
{1, 2, 3, 4, 5}

Example 2
Transform the rows of a numeric table into textual records.
Usage

[Link](
[Link]({
[a = 1],
[a = 2],
[a = 3],
[a = 4],
[a = 5]
}),
(row) as record => [B = [Link](row[a])]
)

Output
{
[B = "1"],
[B = "2"],
[B = "3"],
[B = "4"],
[B = "5"]
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional columns as any) as table

About
Makes columns into rows and rows into columns.

Example 1
Make the rows of the table of name-value pairs into columns.
Usage

[Link](
[Link]({
[Name = "Full Name", Value = "Fred"],
[Name = "Age", Value = 42],
[Name = "Country", Value = "UK"]
})
)

Output

[Link]({
[Column1 = "Full Name", Column2 = "Age", Column3 = "Country"],
[Column1 = "Fred", Column2 = 42, Column3 = "UK"]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, pivotColumns as list, attributeColumn as text, valueColumn as
text) as table

About
Translates a set of columns in a table into attribute-value pairs, combined with the rest of the values in each row.

Example 1
Take the columns "a", "b", and "c" in the table
({[ key = "x", a = 1, b = null, c = 3 ], [ key = "y", a = 2, b = 4, c = null ]}) and unpivot them into
attribute-value pairs.
Usage

[Link](
[Link]({
[key = "x", a = 1, b = null, c = 3],
[key = "y", a = 2, b = 4, c = null]
}),
{"a", "b", "c"},
"attribute",
"value"
)

Output

[Link]({
[key = "x", attribute = "a", value = 1],
[key = "x", attribute = "c", value = 3],
[key = "y", attribute = "a", value = 2],
[key = "y", attribute = "b", value = 4]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, pivotColumns as list, attributeColumn as text,
valueColumn as text) as table

About
Translates all columns other than a specified set into attribute-value pairs, combined with the rest of the values
in each row.

Example 1
Translates all columns other than a specified set into attribute-value pairs, combined with the rest of the values
in each row.
Usage

[Link](
[Link]({
[key = "key1", attribute1 = 1, attribute2 = 2, attribute3 = 3],
[key = "key2", attribute1 = 4, attribute2 = 5, attribute3 = 6]
}),
{"key"},
"column1",
"column2"
)

Output

[Link]({
[key = "key1", column1 = "attribute1", column2 = 1],
[key = "key1", column1 = "attribute2", column2 = 2],
[key = "key1", column1 = "attribute3", column2 = 3],
[key = "key2", column1 = "attribute1", column2 = 4],
[key = "key2", column1 = "attribute2", column2 = 5],
[key = "key2", column1 = "attribute3", column2 = 6]
})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as nullable table, handlers as record) as table

About
Returns a view of table where the functions specified in handlers are used in lieu of the default behavior of an
operation when the operation is applied to the view.
If table is provided, all handler functions are optional. If table isn't provided, the GetType and GetRows
handler functions are required. If a handler function isn't specified for an operation, the default behavior of the
operation is applied to table instead (except in the case of GetExpression ).
Handler functions must return a value that is semantically equivalent to the result of applying the operation
against table (or the resulting view in the case of GetExpression ).
If a handler function raises an error, the default behavior of the operation is applied to the view.
[Link] can be used to implement folding to a data source—the translation of M queries into source-
specific queries (for example, to create T-SQL statements from M queries).
Refer to the published Power Query custom connector documentation for a more complete description of
[Link] .

Example 1
Create a basic view that doesn't require accessing the rows in order to determine the type or the row count.
Usage

[Link](
null,
[
GetType = () => type table [CustomerID = number, Name = text, Phone = nullable text],
GetRows = () => [Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]}),
GetRowCount = () => 1
]
)

Output
[Link]({[CustomerID = 1, Name = "Bob", Phone = "123-4567"]})
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](errorRecord as record) as record

About
Creates a modified error record from errorRecord which won't trigger a fallback when thrown by a handler
defined on a view (via [Link]).
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](function as function) as function

About
Creates a view function based on function that can be handled in a view created by [Link].
The OnInvoke handler of [Link] can be used to defined a handler for the view function.
As with the handlers for built-in operations, if no OnInvoke handler is specified, or if it does not handle the view
function, or if an error is raised by the handler, function is applied on top of the view.
Refer to the published Power Query custom connector documentation for a more complete description of
[Link] and custom view functions.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](tables as table, optional dataColumn as nullable text) as table

About
Gets the relationships among a set of tables. The set tables is assumed to have a structure similar to that of a
navigation table. The column defined by dataColumn contains the actual data tables.
#table
9/13/2022 • 2 minutes to read

Syntax
#table(columns as any, rows as any) as any

About
Creates a table value from columns and rows . The columns value can be a list of column names, a table type, a
number of columns, or null. The rows value is a list of lists, where each element contains the column values for
a single row.

Example 1
Create an empty table.
Usage

#table({}, {})

Output

#table({}, {})

Example 2
Create a table by inferring the number of columns from the first row.
Usage

#table(null, {{"Betty", 90.3}, {"Carl", 89.5}})

Output

#table({"Column1", "Column2"}, {{"Betty", 90.3}, {"Carl", 89.5}})

Example 3
Create a table by specifying the number of columns.
Usage

#table(2, {{"Betty", 90.3}, {"Carl", 89.5}})

Output
#table({"Column1", "Column2"}, {{"Betty", 90.3}, {"Carl", 89.5}})

Example 4
Create a table by providing a list of column names.
Usage

#table({"Name", "Score"}, {{"Betty", 90.3}, {"Carl", 89.5}})

Output

#table({"Name", "Score"}, {{"Betty", 90.3}, {"Carl", 89.5}})

Example 5
Create a table with an explicit type.
Usage

#table(type table [Name = text, Score = number], {{"Betty", 90.3}, {"Carl", 89.5}})

Output

#table(type table [Name = text, Score = number], {{"Betty", 90.3}, {"Carl", 89.5}})
Text functions
9/13/2022 • 3 minutes to read

These functions create and manipulate text values.

Information
NAME DESC RIP T IO N

[Link] Infers the granular number type ([Link], [Link],


and so on) of a number encoded in text.

[Link] Returns the number of characters in a text value.

Text Comparisons
NAME DESC RIP T IO N

[Link] Returns a number to its character value.

[Link] Returns a character to its number value.

[Link] Returns a [Link] value from the given value .

[Link] Produces a JSON representation of a given value.

[Link] Returns the text representation of a number, date, time,


datetime, datetimezone, logical, duration or binary value. If a
value is null, [Link] returns null. The optional culture
parameter is used to format the text value according to the
given culture.

[Link] Decodes data from a binary value in to a text value using an


encoding.

[Link] Returns a Guid value as a text value.

[Link] Encodes a text value into binary value using an encoding.

[Link] Returns a list of characters from a text value.

[Link] Decodes a value from a textual representation, value, and


interprets it as a value with an appropriate type.
[Link] takes a text value and returns a number, a
logical value, a null value, a DateTime value, a Duration
value, or a text value. The empty text value is interpreted as
a null value.

Extraction
NAME DESC RIP T IO N

[Link] Returns a character starting at a zero-based offset.

[Link] Returns the substring up to a specific length.

[Link] Returns a number of characters from a text value starting at


a zero-based offset and for count number of characters.

[Link] Returns the count of characters from the start of a text


value.

[Link] Returns the number of characters from the end of a text


value.

Modification
NAME DESC RIP T IO N

[Link] Returns a text value with newValue inserted into a text value
starting at a zero-based offset.

[Link] Removes all occurrences of a character or list of characters


from a text value. The removeChars parameter can be a
character value or a list of character values.

[Link] Removes count characters at a zero-based offset from a text


value.

[Link] Replaces all occurrences of a substring with a new text value.

[Link] Replaces length characters in a text value starting at a zero-


based offset with the new text value.

[Link] Selects all occurrences of the given character or list of


characters from the input text value.

Membership
NAME DESC RIP T IO N

[Link] Returns true if a text value substring was found within a text
value string; otherwise, false.

[Link] Returns a logical value indicating whether a text value


substring was found at the end of a string.

[Link] Returns the first occurrence of substring in a string and


returns its position starting at startOffset.

[Link] Returns the first occurrence of a text value in list and returns
its position starting at startOffset.
NAME DESC RIP T IO N

[Link] Returns a logical value indicating whether a text value


substring was found at the beginning of a string.

Transformations
NAME DESC RIP T IO N

[Link] Returns the portion of text after the specified delimiter.

[Link] Returns the portion of text before the specified delimiter.

[Link] Returns the portion of text between the specified


startDelimiter and endDelimiter.

[Link] Returns the original text value with non-printable characters


removed.

[Link] Returns a text value that is the result of joining all text values
with each value separated by a separator.

[Link] Returns the lowercase of a text value.

[Link] Returns a text value padded at the end with pad to make it
at least length characters.

[Link] Returns a text value padded at the beginning with pad to


make it at least length characters. If pad is not specified,
whitespace is used as pad.

[Link] Returns a text value with first letters of all words converted
to uppercase.

[Link] Returns a text value composed of the input text value


repeated a number of times.

[Link] Reverses the provided text.

[Link] Returns a list containing parts of a text value that are


delimited by a separator text value.

[Link] Returns a list containing parts of a text value that are


delimited by any separator text values.

[Link] Removes any occurrences of characters in trimChars from


text.

[Link] Removes any occurrences of the characters specified in


trimChars from the end of the original text value.

[Link] Removes any occurrences of the characters in trimChars


from the start of the original text value.
NAME DESC RIP T IO N

[Link] Returns the uppercase of a text value.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](number as nullable number) as nullable text

About
Returns the character equivalent of the number.

Example 1
Given the number 9, find the character value.
Usage

[Link](9)

Output
"#(tab)"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](character as nullable text) as nullable number

About
Returns the number equivalent of the character, character .

Example 1
Given the character "#(tab)" 9, find the number value.
Usage

[Link]("#(tab)")

Output
9
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as nullable text) as nullable text

About
Returns a [Link] value from the given value . If the given value is null , [Link] returns null . A
check will be performed to determine if the given value is in an acceptable format. Acceptable formats
provided in the examples.

Example 1
The Guid can be provided as 32 contiguous hexadecimal digits.
Usage

[Link]("05FE1DADC8C24F3BA4C2D194116B4967")

Output
"05fe1dad-c8c2-4f3b-a4c2-d194116b4967"

Example 2
The Guid can be provided as 32 hexadecimal digits separated by hyphens into blocks of 8-4-4-4-12.
Usage

[Link]("05FE1DAD-C8C2-4F3B-A4C2-D194116B4967")

Output
"05fe1dad-c8c2-4f3b-a4c2-d194116b4967"

Example 3
The Guid can be provided as 32 hexadecimal digits separated by hyphens and enclosed in braces.
Usage

[Link]("{05FE1DAD-C8C2-4F3B-A4C2-D194116B4967}")

Output
"05fe1dad-c8c2-4f3b-a4c2-d194116b4967"
Example 4
The Guid can be provided as 32 hexadecimal digits separated by hyphens and enclosed by parentheses.
Usage

[Link]("(05FE1DAD-C8C2-4F3B-A4C2-D194116B4967)")

Output
"05fe1dad-c8c2-4f3b-a4c2-d194116b4967"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional encoding as nullable number) as binary

About
Produces a JSON representation of a given value value with a text encoding specified by encoding . If
encoding is omitted, UTF8 is used. Values are represented as follows:

Null, text and logical values are represented as the corresponding JSON types
Numbers are represented as numbers in JSON, except that #infinity , -#infinity and #nan are converted
to null
Lists are represented as JSON arrays
Records are represnted as JSON objects
Tables are represented as an array of objects
Dates, times, datetimes, datetimezones and durations are represented as ISO-8601 text
Binary values are represented as base-64 encoded text
Types and functions produce an error

Example 1
Convert a complex value to JSON.
Usage

[Link]([Link]([A = {1, true, "3"}, B = #date(2012, 3, 25)]))

Output
"{""A"":[1,true,""3""],""B"":""2012-03-25""}"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, delimiter as text, optional index as any) as any

About
Returns the portion of text after the specified delimiter . An optional numeric index indicates which
occurrence of the delimiter should be considered. An optional list index indicates which occurrence of the
delimiter should be considered, as well as whether indexing should be done from the start or end of the input.

Example 1
Get the portion of "111-222-333" after the (first) hyphen.
Usage

[Link]("111-222-333", "-")

Output
"222-333"

Example 2
Get the portion of "111-222-333" after the second hyphen.
Usage

[Link]("111-222-333", "-", 1)

Output
"333"

Example 3
Get the portion of "111-222-333" after the second hyphen from the end.
Usage

[Link]("111-222-333", "-", {1, [Link]})

Output
"222-333"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, index as number) as nullable text

About
Returns the character in the text value, text at position index . The first character in the text is at position 0.

Example 1
Find the character at position 4 in string "Hello, World".
Usage

[Link]("Hello, World", 4)

Output
"o"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, delimiter as text, optional index as any) as any

About
Returns the portion of text before the specified delimiter . An optional numeric index indicates which
occurrence of the delimiter should be considered. An optional list index indicates which occurrence of the
delimiter should be considered, as well as whether indexing should be done from the start or end of the input.

Example 1
Get the portion of "111-222-333" before the (first) hyphen.
Usage

[Link]("111-222-333", "-")

Output
"111"

Example 2
Get the portion of "111-222-333" before the second hyphen.
Usage

[Link]("111-222-333", "-", 1)

Output
"111-222"

Example 3
Get the portion of "111-222-333" before the second hyphen from the end.
Usage

[Link]("111-222-333", "-", {1, [Link]})

Output
"111"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, startDelimiter as text, endDelimiter as text,
optional startIndex as any, optional endIndex as any) as any

About
Returns the portion of text between the specified startDelimiter and endDelimiter . An optional numeric
startIndex indicates which occurrence of the startDelimiter should be considered. An optional list
startIndex indicates which occurrence of the startDelimiter should be considered, as well as whether
indexing should be done from the start or end of the input. The endIndex is similar, except that indexing is done
relative to the startIndex .

Example 1
Get the portion of "111 (222) 333 (444)" between the (first) open parenthesis and the (first) closed parenthesis
that follows it.
Usage

[Link]("111 (222) 333 (444)", "(", ")")

Output
"222"

Example 2
Get the portion of "111 (222) 333 (444)" between the second open parenthesis and the first closed parenthesis
that follows it.
Usage

[Link]("111 (222) 333 (444)", "(", ")", 1, 0)

Output
"444"

Example 3
Get the portion of "111 (222) 333 (444)" between the second open parenthesis from the end and the second
closed parenthesis that follows it.
Usage
[Link]("111 (222) 333 (444)", "(", ")", {1, [Link]}, {1,
[Link]})

Output
"222) 333 (444"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text) as nullable text

About
Returns a text value with all control characters of text removed.

Example 1
Remove line feeds and other control characters from a text value.
Usage

[Link]("ABC#(lf)D")

Output
"ABCD"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](texts as list, optional separator as nullable text) as text

About
Returns the result of combining the list of text values, texts , into a single text value. An optional separator used
in the final combined text may be specified, separator .

Example 1
Combine text values "Seattle" and "WA".
Usage

[Link]({"Seattle", "WA"})

Output
"SeattleWA"

Example 2
Combine text values "Seattle" and "WA" separated by a comma and a space, ", ".
Usage

[Link]({"Seattle", "WA"}, ", ")

Output
"Seattle, WA"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, substring as text, optional comparer as nullable function)
as nullable logical

About
Detects whether text contains the value substring . Returns true if the value is found. This function doesn't
support wildcards or regular expressions.
The optional argument comparer can be used to specify case-insensitive or culture and locale-aware
comparisons. The following built-in comparers are available in the formula language:
[Link]: Used to perform a case-sensitive ordinal comparison
[Link]: Used to perform a case-insensitive ordinal comparison
[Link]: Used to perform a culture-aware comparison

Example 1
Find if the text "Hello World" contains "Hello".
Usage

[Link]("Hello World", "Hello")

Output
true

Example 2
Find if the text "Hello World" contains "hello".
Usage

[Link]("Hello World", "hello")

Output
false

Example 3
Find if the text "Hello World" contains "hello", using a case-insensitive comparer.
Usage
[Link]("Hello World", "hello", [Link])

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, count as number) as nullable text

About
Returns a text value that is the last count characters of the text value text .

Example 1
Get the last 5 characters of the text "Hello, World".
Usage

[Link]("Hello, World", 5)

Output
"World"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, substring as text, optional comparer as nullable function)
as nullable logical

About
Indicates whether the given text, text , ends with the specified value, substring . The indication is case sensitive.
comparer is a Comparer which is used to control the comparison. Comparers can be used to provide case-
insensitive or culture and locale-aware comparisons.
The following built-in comparers are available in the formula language:
[Link]: Used to perform an exact ordinal comparison
[Link]: Used to perform an exact ordinal case-insensitive comparison
[Link]: Used to perform a culture-aware comparison

Example 1
Check if "Hello, World" ends with "world".
Usage

[Link]("Hello, World", "world")

Output
false

Example 2
Check if "Hello, World" ends with "World".
Usage

[Link]("Hello, World", "World")

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](formatString as text, arguments as any, optional culture as nullable text) as text

About
Returns formatted text that is created by applying arguments from a list or record to a format string
formatString . An optional culture may also be provided (for example, "en-US").

Example 1
Format a list of numbers.
Usage

[Link]("#{0}, #{1}, and #{2}.", {17, 7, 22})

Output
"17, 7, and 22."

Example 2
Format different data types from a record according to United States English culture.
Usage

[Link](
"The time for the #[distance] km run held in #[city] on #[date] was #[duration].",
[
city = "Seattle",
date = #date(2015, 3, 10),
duration = #duration(0, 0, 54, 40),
distance = 10
],
"en-US"
)

Output
"The time for the 10 km run held in Seattle on 3/10/2015 was [Link]."
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable text

About
Returns the text representation of value . The value can be a number , date, time , datetime , datetimezone ,
logical , duration or binary value. If the given value is null, [Link] returns null. An optional culture
may also be provided (for example, "en-US").

Example 1
Create a text value from the number 3.
Usage

[Link](3)

Output
"3"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](binary as nullable binary, optional encoding as nullable number) as nullable
text

About
Decodes data, binary , from a binary value in to a text value, using encoding type.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text, optional culture as nullable text) as type

About
Infers the granular number type ([Link], [Link], and so on) of text . An error is raised if text is not a
number. An optional culture may also be provided (for example, "en-US").
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, offset as number, newText as text) as nullable text

About
Returns the result of inserting text value newText into the text value text at position offset . Positions start at
number 0.

Example 1
Insert "C" between "B" and "D" in "ABD".
Usage

[Link]("ABD", 2, "C")

Output
"ABCD"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text) as nullable number

About
Returns the number of characters in the text text .

Example 1
Find how many characters are in the text "Hello World".
Usage

[Link]("Hello World")

Output
11
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional culture as nullable text) as nullable text

About
Returns the result of converting all characters in text to lowercase. An optional culture may also be provided
(for example, "en-US").

Example 1
Get the lowercase version of "AbCd".
Usage

[Link]("AbCd")

Output
"abcd"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, start as number, optional count as nullable number) as
nullable text

About
Returns count characters, or through the end of text ; at the offset start .

Example 1
Find the substring from the text "Hello World" starting at index 6 spanning 5 characters.
Usage

[Link]("Hello World", 6, 5)

Output
"World"

Example 2
Find the substring from the text "Hello World" starting at index 6 through the end.
Usage

[Link]("Hello World", 6, 20)

Output
"World"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link]() as text

About
Returns a new, random globally unique identifier (GUID).
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, count as number, optional character as nullable text) as
nullable text

About
Returns a text value padded to length count by inserting spaces at the end of the text value text . An
optional character character can be used to specify the character used for padding. The default pad character is
a space.

Example 1
Pad the end of a text value so it is 10 characters long.
Usage

[Link]("Name", 10)

Output

"Name "

Example 2
Pad the end of a text value with "|" so it is 10 characters long.
Usage

[Link]("Name", 10, "|")

Output

"Name||||||"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, count as number, optional character as nullable text) as
nullable text

About
Returns a text value padded to length count by inserting spaces at the start of the text value text . An
optional character character can be used to specify the character used for padding. The default pad character is
a space.

Example 1
Pad the start of a text value so it is 10 characters long.
Usage

[Link]("Name", 10)

Output

" Name"

Example 2
Pad the start of a text value with "|" so it is 10 characters long.
Usage

[Link]("Name", 10, "|")

Output

"||||||Name"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text, substring as text, optional occurrence as nullable number,
optional comparer as nullable function) as any

About
Returns the position of the specified occurrence of the text value substring found in text . An optional
parameter occurrence may be used to specify which occurrence position to return (first occurrence by default).
Returns -1 if substring was not found.
comparer is a Comparer which is used to control the comparison. Comparers can be used to provide case-
insensitive or culture and locale-aware comparisons.
The following built-in comparers are available in the formula language:
[Link] : Used to perform an exact ordinal comparison
[Link] : Used to perform an exact ordinal case-insensitive comparison
[Link] : Used to perform a culture-aware comparison

Example 1
Get the position of the first occurrence of "World" in the text "Hello, World! Hello, World!".
Usage

[Link]("Hello, World! Hello, World!", "World")

Output
7

Example 2
Get the position of last occurrence of "World" in "Hello, World! Hello, World!".
Usage

[Link]("Hello, World! Hello, World!", "World", [Link])

Output
21
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text, characters as list, optional occurrence as nullable number) as
any

About
Returns the position of the first occurrence of any of the characters in the character list text found in the text
value characters . An optional parameter occurrence may be used to specify which occurrence position to
return.

Example 1
Find the position of "W" in text "Hello, World!".
Usage

[Link]("Hello, World!", {"W"})

Output
7

Example 2
Find the position of "W" or "H" in text "Hello, World!".
Usage

[Link]("Hello, World!", {"H", "W"})

Output
0
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional culture as nullable text) as nullable text

About
Returns the result of capitalizing only the first letter of each word in text value text . All other letters are
returned in lowercase. An optional culture may also be provided (for example, "en-US").

Example 1
Use [Link] on a simple sentence.
Usage

[Link]("the QUICK BrOWn fOx jUmPs oVER tHe LAzy DoG")

Output
"The Quick Brown Fox Jumps Over The Lazy Dog"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, offset as number, optional count as nullable number) as
nullable text

About
Returns the substring from the text text found at the offset offset . An optional parameter, count , can be
included to specify how many characters to return. Throws an error if there aren't enough characters.

Example 1
Find the substring from the text "Hello World" starting at index 6.
Usage

[Link]("Hello World", 6)

Output
"World"

Example 2
Find the substring from the text "Hello World Hello" starting at index 6 spanning 5 characters.
Usage

[Link]("Hello World Hello", 6, 5)

Output
"World"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, removeChars as any) as nullable text

About
Returns a copy of the text value text with all the characters from removeChars removed.

Example 1
Remove characters , and ; from the text value.
Usage

[Link]("a,b;c", {",",";"})

Output
"abc"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, offset as number, optional count as nullable number) as
nullable text

About
Returns a copy of the text value text with all the characters from position offset removed. An optional
parameter, count can by used to specify the number of characters to remove. The default value of count is 1.
Position values start at 0.

Example 1
Remove 1 character from the text value "ABEFC" at position 2.
Usage

[Link]("ABEFC", 2)

Output
"ABFC"

Example 2
Remove two characters from the text value "ABEFC" starting at position 2.
Usage

[Link]("ABEFC", 2, 2)

Output
"ABC"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, count as number) as nullable text

About
Returns a text value composed of the input text text repeated count times.

Example 1
Repeat the text "a" five times.
Usage

[Link]("a", 5)

Output
"aaaaa"

Example 2
Repeat the text "helloworld" three times.
Usage

[Link]("helloworld.", 3)

Output
"[Link]."
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, old as text, new as text) as nullable text

About
Returns the result of replacing all occurrences of text value old in text value text with text value new . This
function is case sensitive.

Example 1
Replace every occurrence of "the" in a sentence with "a".
Usage

[Link]("the quick brown fox jumps over the lazy dog", "the", "a")

Output
"a quick brown fox jumps over a lazy dog"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, offset as number, count as number, newText as text) as
nullable text

About
Returns the result of removing a number of characters, count , from text value text beginning at position
offset and then inserting the text value newText at the same position in text .

Example 1
Replace a single character at position 2 in text value "ABGF" with new text value "CDE".
Usage

[Link]("ABGF", 2, 1, "CDE")

Output
"ABCDEF"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text) as nullable text

About
Reverses the provided text .

Example 1
Reverse the text "123".
Usage

[Link]("123")

Output
"321"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, selectChars as any) as nullable text

About
Returns a copy of the text value text with all the characters not in selectChars removed.

Example 1
Select all characters in the range of 'a' to 'z' from the text value.
Usage

[Link]("a,b;c", {"a".."z"})

Output
"abc"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text, separator as text) as list

About
Returns a list of text values resulting from the splitting a text value text based on the specified delimiter,
separator .

Example 1
Create a list from the "|" delimited text value "Name|Address|PhoneNumber".
Usage

[Link]("Name|Address|PhoneNumber", "|")

Output

{
"Name",
"Address",
"PhoneNumber"
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text, separators as text) as list

About
Returns a list of text values resulting from the splitting a text value text based on any character in the specified
delimiter, separators .

Example 1
Create a list from the text value "Jamie|Campbell|Admin|Adventure Works|[Link]".
Usage

[Link]("Jamie|Campbell|Admin|Adventure Works|[Link]", "|")

Output

{
"Jamie",
"Campbell",
"Admin",
"Adventure Works",
"[Link]"
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, count as number) as nullable text

About
Returns the first count characters of text as a text value.

Example 1
Get the first 5 characters of "Hello, World".
Usage

[Link]("Hello, World", 5)

Output
"Hello"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, substring as text, optional comparer as nullable
function) as nullable logical

About
Returns true if text value text starts with text value substring .
text :A value which is to be searched
text
substring : A text value which is the substring to be searched for in substring
comparer : [Optional] A Comparer used for controlling the comparison. For example,
[Link] may be used to perform case-insensitive searches

comparer is a Comparer which is used to control the comparison. Comparers can be used to provide case-
insensitive or culture and locale-aware comparisons.
The following built-in comparers are available in the formula language:
[Link] : Used to perform an exact ordinal comparison
[Link] : Used to perform an exact ordinal case-insensitive comparison
[Link] : Used to perform a culture-aware comparison

Example 1
Check if the text "Hello, World" starts with the text "hello".
Usage

[Link]("Hello, World", "hello")

Output
false

Example 2
Check if the text "Hello, World" starts with the text "Hello".
Usage

[Link]("Hello, World", "Hello")

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional encoding as nullable number, optional
includeByteOrderMark as nullable logical) as nullable binary

About
Encodes the given text value, text , into a binary value using the specified encoding .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as text) as list

About
Returns a list of character values from the given text value text .

Example 1
Create a list of character values from the text "Hello World".
Usage

[Link]("Hello World")

Output

"H",
"e",
"l",
"l",
"o",
" ",
"W",
"o",
"r",
"l",
"d"
}
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional trim as any) as nullable text

About
Returns the result of removing all leading and trailing whitespace from text value text .

Example 1
Remove leading and trailing whitespace from " a b c d ".
Usage

[Link](" a b c d ")

Output
"a b c d"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional trim as any) as nullable text

About
Returns the result of removing all trailing whitespace from text value text .

Example 1
Remove trailing whitespace from " a b c d ".
Usage

[Link](" a b c d ")

Output

" a b c d"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional trim as any) as nullable text

About
Returns the result of removing all leading whitespace from text value text .

Example 1
Remove leading whitespace from " a b c d ".
Usage**

[Link](" a b c d ")

Output

"a b c d "
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional culture as nullable text) as nullable text

About
Returns the result of converting all characters in text to uppercase. An optional culture may also be provided
(for example, "en-US").

Example 1
Get the uppercase version of "aBcD".
Usage

[Link]("aBcD")

Output
"ABCD"
Time functions
9/13/2022 • 2 minutes to read

These functions create and manipulate time values.

NAME DESC RIP T IO N

[Link] Returns a DateTime value from the end of the hour.

[Link] Returns a time value from a value.

[Link] Creates a Time from local, universal, and custom Time


formats.

[Link] Returns an hour value from a DateTime value.

[Link] Returns a minute value from a DateTime value.

[Link] Returns a second value from a DateTime value

[Link] Returns the first value of the hour from a time value.

[Link] Returns a record containing parts of a Date value.

[Link] Returns a text value from a Time value.

#time Creates a time value from hour, minute, and second.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns a time , datetime , or datetimezone value representing the end of the hour in dateTime , including
fractional seconds. Time zone information is preserved.
dateTime :A time , datetime , or datetimezone value from which the end of the hour is calculated.

Example 1
Get the end of the hour for 5/14/2011 [Link] PM.
Usage

[Link](#datetime(2011, 5, 14, 17, 0, 0))

Output
#datetime(2011, 5, 14, 17, 59, 59.9999999)

Example 2
Get the end of the hour for 5/17/2011 [Link] PM -7:00.
Usage

[Link](#datetimezone(2011, 5, 17, 5, 0, 0, -7, 0))

Output
#datetimezone(2011, 5, 17, 5, 59, 59.9999999, -7, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional culture as nullable text) as nullable time

About
Returns a time value from the given value . An optional culture may also be provided (for example, "en-US").
If the given value is null , [Link] returns null . If the given value is time , value is returned. Values of
the following types can be converted to a time value:
text :A value from textual representation. Refer to [Link] for details.
time
datetime : The time component of the value .
datetimezone : The time component of the local datetime equivalent of value .
number : A time equivalent to the number of fractional days expressed by value . If value is negative or
greater or equal to 1, an error is returned.
If value is of any other type, an error is returned.

Example 1
Convert 0.7575 to a time value.
Usage

[Link](0.7575)

Output
#time(18, 10, 48)

Example 2
Convert #datetime(1899, 12, 30, 06, 45, 12) to a time value.
Usage

[Link](#datetime(1899, 12, 30, 06, 45, 12))

Output
#time(06, 45, 12)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as nullable text, optional options as any) as nullable time

About
Creates a time value from a textual representation, text . An optional record parameter, options , may be
provided to specify additional properties. The record can contain the following fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in parsing the time using a best effort.
Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"tt" is "AM" or "PM" , while in "ar-EG" "tt" is "‫ "ص‬or "‫ "م‬. When Format is null , Culture controls
the default format to use. When Culture is null or omitted, [Link] is used.
To support legacy workflows, options may also be a text value. This has the same behavior as if
options = [Format = null, Culture = options] .

Example 1
Convert "[Link]m" into a Time value.
Usage

[Link]("[Link]m")

Output
#time(10, 12, 31)

Example 2
Convert "1012" into a Time value.
Usage

[Link]("1012")

Output
#time(10, 12, 00)

Example 3
Convert "10" into a Time value.
Usage

[Link]("10")

Output
#time(10, 00, 00)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns the hour component of the provided time , datetime , or datetimezone value, dateTime .

Example 1
Find the hour in #datetime(2011, 12, 31, 9, 15, 36).
Usage

[Link](#datetime(2011, 12, 31, 9, 15, 36))

Output
9
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number

About
Returns the minute component of the provided time , datetime , or datetimezone value, dateTime .

Example 1
Find the minute in #datetime(2011, 12, 31, 9, 15, 36).
Usage

[Link](#datetime(2011, 12, 31, 9, 15, 36))

Output
15
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as nullable number`

About
Returns the second component of the provided time , datetime , or datetimezone value, dateTime .

Example 1
Find the second value from a datetime value.
Usage

[Link](#datetime(2011, 12, 31, 9, 15, 36.5))

Output
36.5
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](dateTime as any) as any

About
Returns the first value of the hour given a time , datetime or datetimezone type.

Example 1
Find the start of the hour for October 10th, 2011, [Link]M ( #datetime(2011, 10, 10, 8, 10, 32) ).
Usage

[Link](#datetime(2011, 10, 10, 8, 10, 32))

Output
#datetime(2011, 10, 10, 8, 0, 0)
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](time as time) as record

About
Returns a record containing the parts of the given Time value, time .
time :A time value for from which the record of its parts is to be calculated.

Example 1
Convert the #time(11, 56, 2) value into a record containing Time values.
Usage

[Link](#time(11, 56, 2))

Output

[
Hour = 11,
Minute = 56,
Second = 2
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](time as nullable time, optional options as any, optional culture as nullable text)
as nullable text

About
Returns a textual representation of time . An optional record parameter, options , may be provided to specify
additional properties. culture is only used for legacy workflows. The record can contain the following fields:
Format : A text value indicating the format to use. For more details, go to
[Link] and [Link]
Omitting this field or providing null will result in formatting the date using the default defined by
Culture .

Culture : When Format is not null, Culture controls some format specifiers. For example, in "en-US"
"tt" is "AM" or "PM" , while in "ar-EG" "tt" is "‫ "ص‬or "‫ "م‬. When Format is null , Culture controls
the default format to use. When Culture is null or omitted, [Link] is used.
To support legacy workflows, options and culture may also be text values. This has the same behavior as if
options = [Format = options, Culture = culture] .

Example 1
Convert #time(01, 30, 25) into a text value. Result output may vary depending on current culture.
Usage

[Link](#time(11, 56, 2))

Output
"11:56 AM"

Example 2
Convert using a custom format and the German culture.
Usage

[Link](#time(11, 56, 2), [Format="hh:mm", Culture="de-DE"])

Output
"11:56"
Example 3
Convert using standard time format.
Usage

[Link](#time(11, 56, 2), [Format="T", Culture="de-DE"])

Output
"[Link]"
#time
9/13/2022 • 2 minutes to read

Syntax
#time(hour as number, minute as number, second as number) as time

About
Creates a time value from numbers representing the hour, minute, and (fractional) second. Raises an error if
these conditions are not true:
0 ≤ hour ≤ 24
0 ≤ minute ≤ 59
0 ≤ second < 60
if hour is 24, then minute and second must be 0
Type functions
9/13/2022 • 2 minutes to read

These functions create and manipulate type values.

NAME DESC RIP T IO N

[Link] Add a key to a table type.

[Link] The given type must be a record type returns a closed


version of the given record type (or the same type, if it is
already closed)

[Link] Returns the facets of a type.

[Link] Creates a function type from the given .

[Link] Returns a Record type from a fields record.

[Link] Returns a record with field values set to the name of the
parameters of a function type, and their values set to their
corresponding types.

[Link] Returns a number indicating the minimum number of


parameters required to invoke the a type of function.

[Link] Returns a type returned by a function type.

[Link] Determines if a value of the first type is always compatible


with the second type.

[Link] Returns true if a type is a nullable type; otherwise, false.

[Link] Returns whether a record type is open.

[Link] Returns an item type from a list type.

[Link] Returns the non nullable type from a type.

[Link] Returns an opened version of a record type, or the same


type, if it is already open.

[Link] Returns a record describing the fields of a record type with


each field of the returned record type having a
corresponding name and a value that is a record of the form
[ Type = type, Optional = logical ] .

[Link] Replaces the facets of a type.

[Link] Replaces the keys in a table type.


NAME DESC RIP T IO N

[Link] Returns the type of a column in a table.

[Link] Returns keys from a table type.

[Link] Returns a row type from a table type.

[Link] Returns a table containing a description of the columns (i.e.


the schema) of the specified table type.

[Link] Returns the union of a list of types.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as type, columns as list, isPrimary as logical) as type

About
Adds a key to the given table type.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as type

About
Returns a closed version of the given record type (or the same type, if it is already closed).

Example 1
Create a closed version of type [ A = number,…] .
Usage

[Link](type [A = number, ...])

Output
type [A = number]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as record

About
Returns a record containing the facets of type
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](signature as record, min as number) as type

About
Creates a function type from signature , a record of ReturnType and Parameters , and min , the minimum
number of arguments required to invoke the function.

Example 1
Creates the type for a function that takes a number parameter named X and returns a number.
Usage

[Link]([ReturnType = type number, Parameters = [X = type number]], 1)

Output
type function (X as number) as number
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](fields as record, open as logical) as type

About
Returns a type that represents records with specific type constraints on fields.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as record

About
Returns a record with field values set to the name of the parameters of type , and their values set to their
corresponding types.

Example 1
Find the types of the parameters to the function (x as number, y as text) .
Usage

[Link](type function (x as number, y as text) as any)

Output
[x = type number, y = type text]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as number

About
Returns a number indicating the minimum number of parameters required to invoke the input type of
function.

Example 1
Find the number of required parameters to the function (x as number, optional y as text) .
Usage

[Link](type function (x as number, optional y as text) as any)

Output
1
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as type

About
Returns a type returned by a function type .

Example 1
Find the return type of () as any) .
Usage

[Link](type function () as any)

Output
type any
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type1 as type, type2 as type) as logical

About
Determines if a value of type1 is always compatible with type2 .

Example 1
Determine if a value of type number can always also be treated as type any.
Usage

[Link](type number, type any)

Output
true

Example 2
Determine if a value of type any can always also be treated as type number.
Usage

[Link](type any, type number)

Output
false
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as logical

About
Returns true if a type is a nullable type; otherwise, false .

Example 1
Determine if number is nullable.
Usage

[Link](type number)

Output
false

Example 2
Determine if type nullable number is nullable.
Usage

[Link](type nullable number)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as logical

About
Returns a logical indicating whether a record type is open.

Example 1
Determine if the record type [ A = number, ...] is open.
Usage

[Link](type [A = number, ...])

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as type

About
Returns an item type from a list type .

Example 1
Find item type from the list {number} .
Usage

[Link](type {number})

Output
type number
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as type

About
Returns the non nullable type from the type .

Example 1
Return the non nullable type of type nullable number .
Usage

[Link](type nullable number)

Output
type number
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as type

About
Returns an opened version of the given record type (or the same type, if it is already opened).

Example 1
Create an opened version of type [ A = number] .
Usage

[Link](type [A = number])

Output
type [A = number, ...]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type) as record

About
Returns a record describing the fields of a record type . Each field of the returned record type has a
corresponding name and a value, in the form of a record [ Type = type, Optional = logical ] .

Example 1
Find the name and value of the record [ A = number, optional B = any] .
Usage

[Link](type [A = number, optional B = any])

Output

[
A = [Type = type number, Optional = false],
B = [Type = type any, Optional = true]
]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](type as type, facets as record) as type

About
Replaces the facets of type with the facets contained in the record facets .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](tableType as type, keys as list) as type

About
Returns a new table type with all keys replaced by the specified list of keys.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](tableType as type, column as text) as type

About
Returns the type of the column column in the table type tableType .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](tableType as type) as list

About
Returns the possibly empty list of keys for the given table type.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as type) as type

About
Returns the row type of the specified table type. The result will always be a record type.

Example 1
Return the row type information for a simple table.
Usage

let
tableRowType = [Link]([Link](#table({"Column1"}, {})))
in
[Link](tableRowType)

Output
[Column1 = [Type = type any, Optional = false]]
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](tableType as type) as table

About
Returns a table describing the columns of tableType .
Refer to the documentation for [Link] for a description of the resulting table.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](types as list) as type

About
Returns the union of the types in types .
Uri functions
9/13/2022 • 2 minutes to read

These functions create and manipulate URI query strings.

NAME DESC RIP T IO N

[Link] Assemble a record into a URI query string.

[Link] Returns a Uri based on the combination of the base and


relative parts.

[Link] Encodes special characters in accordance with RFC 3986.

[Link] Returns a record value with the fields set to the parts of a
Uri text value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](query as record) as text

About
Assemble the record query into a URI query string, escaping characters as necessary.

Example 1
Encode a query string which contains some special characters.
Usage

[Link]([a = "1", b = "+$"])

Output
"a=1&b=%2B%24"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](baseUri as text, relativeUri as text) as text

About
Returns an absolute URI that is the combination of the input baseUri and relativeUri .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](data as text) as text

About
Encodes special characters in the input data according to the rules of RFC 3986.

Example 1
Encode the special characters in "+money$".
Usage

[Link]("+money$")

Output
"%2Bmoney%24"
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](absoluteUri as text) as record

About
Returns the parts of the input absoluteUri as a record, containing values such as Scheme, Host, Port, Path,
Query, Fragment, UserName and Password.

Example 1
Find the parts of the absolute URI "[Link]".
Usage

[Link]("[Link]")

Output

[
Scheme = "http",
Host = "[Link]",
Port = 80,
Path = "/",
Query = [],
Fragment = "",
UserName = "",
Password = ""
]

Example 2
Decode a percent-encoded string.
Usage

let
UriUnescapeDataString = (data as text) as text => [Link]("[Link] & data)[Query][a]
in
UriUnescapeDataString("%2Bmoney%24")

Output
"+money$"
Value functions
9/13/2022 • 2 minutes to read

These functions evaluate and perform operations on values.

NAME DESC RIP T IO N

[Link] Expresses alternate query plans.

[Link] Returns 1, 0, or -1 based on value1 being greater than,


equal to, or less than the value2. An optional comparer
function can be provided.

[Link] Returns whether two values are equal.

[Link] Returns an abstract syntax tree (AST) that represents the


value's expression.

[Link] Returns the version identity of a value.

[Link] Returns a navigation table containing the available versions


of a value.

[Link] Evaluates a query against a target.

[Link] Returns a logical value or null based on two values .

[Link] If value represents a query that can be optimized, returns


the optimized query. Otherwise returns value.

[Link] Returns the type of the given value.

Arithmetic operations
NAME DESC RIP T IO N

[Link] Returns the sum of the two values.

[Link] Returns the result of dividing the first value by the second.

[Link] Returns the product of the two values.

[Link] Returns the difference of the two values.

Parameter types
NAME DESC RIP T IO N
NAME DESC RIP T IO N

[Link] Returns the value if it is compatible with the specified type.

[Link] Determines whether a value is compatible with the specified


type.

[Link] Replaces the value's type.

IM P L EM EN TAT IO N DESC RIP T IO N

[Link] This function is intended for internal use only.

[Link] Accesses a value by name in an embedded mashup.

[Link] This function is intended for internal use only.

[Link] This function is intended for internal use only.

[Link] This function is intended for internal use only.

[Link] This function is intended for internal use only.

[Link] This function is intended for internal use only.

Metadata

NAME DESC RIP T IO N

[Link] Returns a record containing the input’s metadata.

[Link] Removes the metadata on the value and returns the original
value.

[Link] Replaces the metadata on a value with the new metadata


record provided and returns the original value with the new
metadata attached.

Lineage
NAME DESC RIP T IO N

[Link] This function is intended for internal use only.

[Link] This function is intended for internal use only.

[Link] This function is intended for internal use only.


[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as table

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, path as text) as any

About
Accesses a value by name in an embedded mashup.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](table as table, optional options as nullable record) as any

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](graph as record) as list

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](schema as any) as any

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](sql as text, environment as record) as text

About
Converts the provided sql query to M code, with the available identifiers defined by environment . This
function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as any

About
Returns the sum of value1 and value2 . An optional precision parameter may be specified, by default
[Link] is used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](alternates as list) as any

About
Expresses alternate query plans within a query plan expression obtained through
[Link]([Link](...)) . Not intended for other uses.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, type as type) as any

About
Returns the value if it's compatible with the specified type. This is equivalent to the "as" operator in M, with the
exception that it can accept identifier type references such as [Link].

Example 1
Cast a number to a number.
Usage

[Link](123, [Link])

Output
123

Example 2
Attempt to cast a text value to a number.
Usage

[Link]("abc", type number)

Output
[[Link]] We cannot convert the value "abc" to type Number.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as number

About
Returns -1, 0, or 1 based on whether the first value is less than, equal to, or greater than the second one.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as any

About
Returns the result of dividing value1 by value2 . An optional precision parameter may be specified, by default
[Link] is used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as logical

About
Returns true if value value1 is equal to value value2 , false otherwise.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as nullable record

About
Returns an abstract syntax tree (AST) that represents the value's expression.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](key as text) as any

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](text as any, optional culture as nullable text) as any

About
Decodes a value from a textual representation, text , and interprets it as a value with an appropriate type.
[Link] takes a text value and returns a number, a logical value, a null value, a datetime value, a duration
value, or a text value. The empty text value is interpreted as a null value. An optional culture may also be
provided (for example, "en-US").
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, type as type) as logical

About
Determines whether a value is compatible with the specified type. This is equivalent to the "is" operator in M,
with the exception that it can accept identifier type references such as [Link].

Example 1
Compare two ways of determining if a number is compatible with type number.
Usage

[Link](123, [Link]) = (123 is number)

Output
true
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as any

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as any

About
Returns a record containing the input's metadata.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as any

About
Returns the product of multiplying value1 by value2 . An optional precision parameter may be specified, by
default [Link] is used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](target as any, query as text, optional parameters as any, optional options as
nullable record) as any

About
Evaluates query against target using the parameters specified in parameters and the options specified in
options .

The output of the query is defined by target .


target provides the context for the operation described by query .
query describes the query to be executed against target . query is expressed in a manner specific to target
(for example, a T-SQL statement).
The optional parameters value may contain either a list or record as appropriate to supply the parameter values
expected by query .
The optional options record may contain options that affect the evaluation behavior of query against target .
These options are specific to target .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as
nullable logical

About
Returns null if either argument value1 , value2 is null, otherwise equivalent to [Link].
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as any

About
When used within [Link], if value represents a query that can be optimized, this function indicates
that the optimized expression should be returned. Otherwise, value will be passed through with no effect.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, optional metaValue as any) as any

About
Strips the input of metadata.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, metaValue as any) as any

About
Replaces the input's metadata information.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any, type as type) as any

About
Replaces the value 's type with the provided type .

Example 1
Replace the default type of a record with a more specific type.
Usage

[Link](
[Link](
[Link](
[Column1 = 123],
type [Column1 = number]
)
)
)[Column1][Type]

Output
type number
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value1 as any, value2 as any, optional precision as nullable number) as any

About
Returns the difference of value1 and value2 . An optional precision parameter may be specified, by default
[Link] is used.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as table

About
This function is intended for internal use only.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as type

About
Returns the type of the given value.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as any

About
Returns the version identity of the value , or null if it doesn't have a version.
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](value as any) as table

About
Returns a navigation table containing the available versions of value .
[Link]
9/13/2022 • 2 minutes to read

Syntax
[Link](identifier as text) as any

About
This function is intended for internal use only.
Enumerations
9/13/2022 • 2 minutes to read

The Power Query M formula language includes these enumerations.

List of enumerations
NAME DESC RIP T IO N

[Link] Specifies the kind of access control.

[Link] Specifies the type of binary encoding.

[Link] Specifies how many times the item is expected to appear in


the group.

[Link] Describes the type of buffering to be performed.

[Link] Specifies the byte order.

[Link] Specifies the type of compression.

[Link] Specifies the significance of quotes in a CSV document.

[Link] Represents the day of the week.

[Link] Specifies the expected action for extra values in a row that
contains columns less than expected.

[Link] Specifies the kind of grouping.

[Link] Specifies the join algorithm to be used in the join operation.

[Link] Specifies the kind of join operation.

[Link] Specifies the left or right table of a join.

[Link] Indicates the features that the specific SQL dialect supports.

[Link] Specifies the expected action for missing values in a row that
contains columns less than expected.

[Link] Specifies the occurrence of an element in a sequence.

[Link] Specifies the kinds of values an OData service can omit.

[Link] Specifies the direction of sorting.

[Link] Specifies the percentile mode type.


NAME DESC RIP T IO N

[Link] Specifies the precision of comparison.

[Link] Specifies the quote style.

[Link] Specifies the precise ranking method.

[Link] Indicates whether indexing should be done from the start or


end of the input.

[Link] Specifies rounding direction when there is a tie between the


possible numbers to round to.

[Link] Specifies valid options for SAP Business Warehouse execution


mode option.

[Link] Specifies valid options for SAP HANA distribution option.

[Link] Specifies a range operator for SAP HANA range input


parameters.

[Link] Specifies the text encoding type.

[Link] Specifies the trace level.

[Link] Specifies an HTTP method.


[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the kind of access control.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Access is denied.

[Link] 1 Access is allowed.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the type of binary encoding.

Allowed values
NAME VA L UE DESC RIP T IO N

Binar yEncoding.Base64 0 Constant to use as the encoding type


when base-64 encoding is required.

Binar [Link] 1 Constant to use as the encoding type


when hexadecimal encoding is
required.

Applies to
Binary functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies how many times the item is expected to appear in the group.

Allowed values
NAME VA L UE DESC RIP T IO N

Binar [Link] 0 The item is expected to appear zero or


one time in the input.

Binar [Link] 1 The item is expected to appear once in


the input.

Binar [Link] 2 The item is expected to appear zero or


more times in the input.

Applies to
Binary functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Describes the type of buffering to be performed.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 1 The entire value is immediately


buffered in memory before continuing.

[Link] 2 The type of the value is computed


immediately but its contents aren't
buffered until data is needed, at which
point the entire value is immediately
buffered.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the byte order.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 The least significant byte appears first


in Little Endian byte order.

[Link] 1 The most significant byte appears first


in Big Endian byte order.

Remarks
The allowed values for this enumeration are possible values for the byteOrder parameter in
[Link].

Applies to
Binary functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the type of compression.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] -1 The data is uncompressed.

[Link] 0 The compressed data is in the 'GZip'


format.

[Link] 1 The compressed data is in the 'Deflate'


format.

[Link] 2 The compressed data is in the 'Snappy'


format.

[Link] 3 The compressed data is in the 'Brotli'


format.

Compression.L Z4 4 The compressed data is in the 'LZ4'


format.

[Link] 5 The compressed data is in the


'Zstandard' format.

Applies to
Binary functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the significance of quotes in CSV documents.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Quotes in a field are only significant


immediately following the delimiter.

[Link] 1 Quotes in a field are always significant


regardless of where they appear.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Represents the day of the week.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Represents Sunday.

[Link] 1 Represents Monday.

[Link] 2 Represents Tuesday.

[Link] 3 Represents Wednesday.

[Link] 4 Represents Thursday.

[Link] 5 Represents Friday.

[Link] 6 Represents Saturday.

Applies to
Date functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the expected action for extra values in a row that contains columns less than expected.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 If the splitter function returns more


columns than the table expects, they
should be collected into a list.

[Link] 1 If the splitter function returns more


columns than the table expects, an
error should be raised.

[Link] 2 If the splitter function returns more


columns than the table expects, they
should be ignored.

Applies to
Accessing data functions
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the kind of grouping.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 A local group is formed from a


consecutive sequence of rows from an
input table with the same key value.

[Link] 1 A global group is formed from all rows


in an input table with the same key
value.

Applies to
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the join algorithm to be used in the join operation.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Automatically chooses a join algorithm


based on inspecting the initial rows
and metadata of both tables.

[Link] wiseHash 1 Buffers the rows of both the left and


right tables until one of the tables is
completely buffered, and then
performs a LeftHash or RightHash,
depending on which table was
buffered completely. This algorithm is
recommended only for small tables.

[Link] tMerge 2 Performs a streaming merge based on


the assumption that both tables are
sorted by their join keys. While
efficient, it will return incorrect results if
the tables aren't sorted as expected.

[Link] 3 Buffers the left rows into a lookup


table and streams the right rows. For
each right row, the matching left rows
are found via the buffered lookup
table. This algorithm is recommended
when the left table is small and most
of the rows from the right table are
expected to match a left row.

[Link] 4 Buffers the right rows into a lookup


table and streams the left rows. For
each left row, the matching right rows
are found via the buffered lookup
table. This algorithm is recommended
when the right table is small and most
of the rows from the left table are
expected to match a right row.

[Link] 5 In batches, uses the keys from the left


table to do predicate-based queries
against the right table. This algorithm
is recommended when the right table
is large, supports folding of
[Link], and contains few
rows that are expected to match a left
row.
NAME VA L UE DESC RIP T IO N

[Link] 6 In batches, uses the keys from the


right table to do predicate-based
queries against the left table. This
algorithm is recommended when the
left table is large, supports folding of
[Link] , and contains few
rows that are expected to match a
right row.

Applies to
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the kind of join operation.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 The table resulting from an inner join


contains a row for each pair of rows
from the specified tables that were
determined to match based on the
specified key columns.

[Link] 1 A left outer join ensures that all rows


of the first table appear in the result.

[Link] 2 A right outer join ensures that all rows


of the second table appear in the
result.

[Link] 3 A full outer join ensures that all rows


of both tables appear in the result.
Rows that did not have a match in the
other table are joined with a default
row containing null values for all of its
columns.

[Link] 4 A left anti join returns that all rows


from the first table which do not have
a match in the second table.

[Link] 5 A right anti join returns that all rows


from the second table which do not
have a match in the first table.

Remarks
The fields of this enumeration are possible values for the optional JoinKind parameter in [Link].

Applies to
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the left or right table of a join.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Specifies the left table of a join.

[Link] 1 Specifies the right table of a join.

Applies to
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Describes the type of limit clause supported by the SQL dialect used by this data source.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 This SQL dialect does not support a


limit clause.

[Link] 1 This SQL dialect supports a TOP


specifier to limit the number of rows
returned.

[Link] 2 This SQL dialect supports LIMIT and


OFFSET specifiers to limit the number
of rows returned.

[Link] 3 This SQL dialect supports a LIMIT


specifier to limit the number of rows
returned.

LimitClauseKind.AnsiSql2008 4 This SQL dialect supports an ANSI


SQL-compatible LIMIT N ROWS
specifier to limit the number of rows
returned.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the expected action for missing values in a row that contains columns less than expected.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Indicates that missing fields should


result in an error. (This is the default
value.)

[Link] 1 Indicates that missing fields should be


ignored.

[Link] 2 Indicates that missing fields should be


included as null values.

Applies to
Record functions
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the occurrence of an element in a sequence.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 The position of the first occurrence of


the found value is returned.

[Link] 1 The position of the last occurrence of


the found value is returned.

[Link] 2 A list of positions of all occurrences of


the found values is returned.

[Link] 0 The item is expected to appear zero or


one time in the input. Provided for
backward compatibility in binary
functions. In this case, use
[Link] instead.

[Link] 1 The item is expected to appear once in


the input. Provided for backward
compatibility in binary functions. In
this case, use
[Link] instead.

[Link] 2 The item is expected to appear zero or


more times in the input. Provided for
backward compatibility in binary
functions. In this case, use
[Link] instead.

Applies to
Table functions
Text functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the kinds of values an OData service can omit.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] "nulls" Allows the OData service to omit null


values.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the direction of sorting.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Sorts the values in ascending order.

[Link] 1 Sorts the values in descending order.

Applies to
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the percentile mode type.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 1 When interpolating values for


[Link], use a method
compatible with Excel's
[Link].

[Link] 2 When interpolating values for


[Link] , use a method
compatible with Excel's
[Link].

[Link] 3 When interpolating values for


[Link] , use a method
compatible with SQL Server's
PERCENTILE_DISC.

[Link] 4 When interpolating values for


[Link] , use a method
compatible with SQL Server's
PERCENTILE_CONT.

Applies to
List functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the precision of comparison.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 An optional parameter for the built-in


arithmetic operators to specify double
precision.

[Link] 1 An optional parameter for the built-in


arithmetic operators to specify decimal
precision.

Applies to
Value functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the quote style.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Quote characters have no significance.

[Link] 1 Quote characters indicate the start of


a quoted string. Nested quotes are
indicated by two quote characters.

Applies to
Splitter functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the precise ranking method.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Items which compare as equal receive


the same ranking number and then a
gap is left before the next ranking.

[Link] 1 Items which compare as equal receive


the same ranking number and the next
item is numbered consecutively with
no gap.

[Link] 2 All items are given a unique ranking


number even if they compare as equal.

Applies to
Table functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Indicates whether indexing should be done from the start or end of the input.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] t 0 Indicates indexing should be done


from the start of the input.

[Link] 1 Indicates indexing should be done


from the end of the input.

Applies to
Text functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies rounding direction when there is a tie between the possible numbers to round to.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 Round up when there is a tie between


the possible numbers to round to.

[Link] 1 Round down when there is a tie


between the possible numbers to
round to.

[Link] 2 Round away from zero when there is a


tie between the possible numbers to
round to.

[Link] 3 Round toward zero when there is a tie


between the possible numbers to
round to.

[Link] 4 Round to the nearest even number


when there is a tie between the
possible numbers to round to.

Applies to
List functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies valid options for SAP Business Warehouse execution mode option.

Allowed values
NAME VA L UE DESC RIP T IO N

SapBusinessWarehouseExecution 64 'bXML flattening mode' option for


[Link] MDX execution in SAP Business
Warehouse.

SapBusinessWarehouseExecution 65 'Gzip compressed bXML flattening


[Link] mode' option for MDX execution in
SAP Business Warehouse.
Recommended for low latency or high
volume queries.

SapBusinessWarehouseExecution 66 'DataStream flattening mode' option


[Link] for MDX execution in SAP Business
Warehouse.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies valid options for SAP HANA distribution option.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 'Off' distribution option for SAP HANA.

[Link] 1 'Connection' distribution option for


SAP HANA.

[Link] 2 'Statement' distribution option for SAP


HANA.

[Link] 3 Returns the packages in an SAP HANA


database.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies a range operator for SAP HANA range input parameters.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 0 'Greater than' range operator for SAP


han HANA input parameters.

[Link] 1 'Less than' range operator for SAP


HANA input parameters.

[Link] 2 'Greater than or equals' range


hanOrEquals operator for SAP HANA input
parameters.

[Link] 3 'Less than or equals' range operator


OrEquals for SAP HANA input parameters.

[Link] 4 'Equals' range operator for SAP HANA


input parameters.

[Link] 5 'Not equals' range operator for SAP


s HANA input parameters.

Applies to
Accessing data functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the text encoding type.

Allowed values
NAME VA L UE DESC RIP T IO N

TextEncoding.Utf16 1200 Use to choose the UTF16 little endian


binary form.

[Link] 1200 Use to choose the UTF16 little endian


binary form.

[Link] 1201 Use to choose the UTF16 big endian


binary form.

[Link] 1252 Use to choose the Windows binary


form.

[Link] 20127 Use to choose the ASCII binary form.

TextEncoding.Utf8 65001 Use to choose the UTF8 binary form.

Applies to
Text functions
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies the trace level.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] 1 Specifies the Critical trace level.

[Link] 2 Specifies the Error trace level.

[Link] 4 Specifies the Warning trace level.

[Link] 8 Specifies the Information trace level.

[Link] 16 Specifies the Verbose trace level.

Applies to
Error handling
[Link]
9/13/2022 • 2 minutes to read

Definition
Specifies an HTTP method.

Allowed values
NAME VA L UE DESC RIP T IO N

[Link] "DELETE" Specifies the DELETE method for HTTP.

[Link] "GET" Specifies the GET method for HTTP.

[Link] "HEAD" Specifies the HEAD method for HTTP.

[Link] "PATCH" Specifies the PATCH method for HTTP.

[Link] "POST" Specifies the POST method for HTTP.

[Link] "PUT" Specifies the PUT method for HTTP.

Remarks
These fields only work in the context of custom connectors.

Applies to
Accessing data functions
Constants
9/13/2022 • 2 minutes to read

The Power Query M formula language includes these constant values.

List of constants
NAME DESC RIP T IO N

Number.E Returns 2.7182818284590451, the value of e up to 16


decimal digits.

[Link] Returns the smallest possible number.

[Link] Represents 0/0.

[Link] Represents -1/0.

[Link] Returns 3.1415926535897931, the value for Pi up to 16


decimal digits.

[Link] Represents 1/0.

See also
Number functions
Number.E
9/13/2022 • 2 minutes to read

About
A constant that represents 2.7182818284590451, the value for e up to 16 decimal digits.
[Link]
9/13/2022 • 2 minutes to read

About
A constant value that represents the smallest positive number a floating-point number can hold.
[Link]
9/13/2022 • 2 minutes to read

About
A constant value that represents 0 divided by 0.
[Link]
9/13/2022 • 2 minutes to read

About
A constant value that represents -1 divided by 0.
[Link]
9/13/2022 • 2 minutes to read

About
A constant that represents 3.1415926535897932, the value for pi up to 16 decimal digits.
[Link]
9/13/2022 • 2 minutes to read

About
A constant value that represents 1 divided by 0.
Dynamic values
9/13/2022 • 2 minutes to read

The Power Query M formula language includes these dynamic values.

List of dynamic values


NAME DESC RIP T IO N

[Link] Returns the name of the current culture for the application.

[Link] Returns the name of the current time zone for the
application.

See also
Comparer functions
DateTimeZone functions
[Link]
9/13/2022 • 2 minutes to read

About
Returns the name of the current culture for the application.
[Link]
9/13/2022 • 2 minutes to read

About
Returns the name of the current time zone for the application.

You might also like