Wrangle Language
Wrangle is the domain-specific language used to build transformation recipes in Designer Cloud.
A Wrangle recipeis a sequence of transformation steps applied to your dataset in order to produce your results.
Transform and transformation:
A transform is a single action applied to a dataset. A transform is part of the underlying Wrangle. Transforms are not directly accessible to users.
A transformation is a user-facing action that you can apply to your dataset through the Transformer page. A transformation is typically a use-specific or more sophisticated manifestation of a transform.
Note
Transforms are a part of the underlying language, which is not directly accessible to users. This content is maintained for reference purposes only. For more information on the user-accessible equivalent to transforms, see Transformation Reference.
Tip
Except for the reference documentation for individual transforms, the language documentation references transformations that you can apply through the Transformer page.
For most of these actions, you can pass one or more parameters to define the context (columns, rows, or conditions).
Function:
Some parameters accept one or more functions. A function is a computational action performed on one or more columns of data in your dataset.
When you select suggestions in the Transformer Page, your selection is converted into a transformation that you can add to your recipe.
Tip
Where possible, you should make selections in the data grid to build transformation steps. These selections prompt a series of cards to be displayed. You can select different cards to specify a basic transformation for your selected data, choose a variant of that transformation, and then modify the underlying Wrangle recipe as necessary.
Wrangle vs. SQL
Note
Wrangle is not SQL. It is a proprietary language of data transformation, purpose-built for Designer Cloud.
While there are some overlaps between Wrangle and SQL, here are the key distinctions:
is a proprietary language designed for data transformation. Every supported transformation is designed to make changes to a dataset. It cannot be used to read from or write to a datastore.
Users interact with Wrangle exclusively through the Cloud Portal. There is no direct interaction with the language.
SQL (Structured Query Language) is designed for querying, transforming, and writing for relational datasources. It cannot be applied to file-based datasets.
SQL cannot be used to transform data in Designer Cloud.
Wrangle Syntax
Wrangle transforms follow this general syntax:
(transform) param1:(expression) param2:(expression)
Transform Element | Description |
---|---|
transform | In Wrangle, a transform (or verb) is a single keyword that identifies the type of change you are applying to your dataset. A transform is always the first keyword in a recipe step. Details are below. Note Transforms are a part of the underlying language, which is not directly accessible to users. This content is maintained for reference purposes only. For more information on the user-accessible equivalent to transforms, see Transformation Reference. The other elements in each step are contextual parameters for the transform. Some transforms do not require parameters. |
| Additional parameters may be optional or required for any transform. Note A parameter is always followed by a colon. A parameter may appear only one time in a transform step. |
Common Parameters
Depending on the transform, one or more of value
, col
, and row
parameters may be used. For example, the set
transform can use all three or just value
and col
.
Transform Element | Description |
---|---|
value: | When present, the An expression can contain combinations of the following:
For more information onWrangle, seeText Matching. |
col: | When present, the Some transforms may support multiple columns as a list, as a range of columns (e.g., |
row: | When present, the |
group: | For aggregating transforms, such as Note Transforms that use the |
order: | For aggregating transforms, such as |
Flow parameters
At the flow level, you can define parameters that can be referenced in your recipe steps.
In the following transformation, the flow parameter currentDiscount
is invoked in the step to yield the discounted cost.
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | TotalCost * (1/${currentDiscount}) |
Parameter: New column name | discountedCost |
Flow parameters are referenced in your steps in the following format:
${MyRecipeParameter}
For more information, see Create Flow Parameter.
Parameter Inputs
The following types of parameter inputs may be referenced in a transform's parameters.
Other Alteryx data types can be referenced as column references. For literal values of these data types, you can insert them into your expressions as strings. Transforms cause the resulting values to be re-inferred for their data type.
Column reference
A reference to the values stored in a column in your dataset. Columns can be referenced by the plain-text value for the column name.
Example: value
parameter references the myCol
column.
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | myCol |
Parameter: New column name | 'myNewCol' |
Column names with spaces or special characters in a transformation must be wrapped by curly braces.
Example: Below, srcColumn
is renamed to src Column
, which requires no braces because the new name is captured as a string literal:
Transformation Name |
|
---|---|
Parameter: Option | Manual rename |
Parameter: Column | srcColumn |
Parameter: New column name | src Column |
Note
Current column names that have a space in them must be bracketed in curly braces. The above column name reference is the following: {src Column}
.
Functions
Some parameters accept functions as inputs. Where values or formulas are calculated, you can reference one of the dozens of functions available in Wrangle.
Example:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | MULTIPLY(3,2) |
Parameter: New column name | 'six' |
Metadata variables
Wrangle supports the use of variable references to aspects of the source data or dataset. In the following example, the ABS function is applied to each column in a set of them using the $col
reference.
Transformation Name |
|
---|---|
Parameter: Columns | val1,val2 |
Parameter: Formula | ABS($col) |
$col
returns the value from the current column for the row under evaluation.For more information on these variables, see Source Metadata References.
Nested expressions
Individual parameters within a function can be computed expressions themselves. These nested expressions can be calculated using constants, other functions, and column references.
Example: Computes a column whose only value is ten divided by three, rounded to the nearest integer (3):
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | ROUND(DIVIDE(10,3),0) |
Parameter: New column name | 'three' |
Integer
A valid integer value within the accepted range of values for the Integer datatype.
Example: Generates a column called, my13
which is the sum of the Integer values 5
and 8
:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | (5 + 8) |
Parameter: New column name | 'my13' |
Decimal
A valid floating point value within the accepted range of values for the Decimal datatype.
Example: Generates a column of values that computes the approximate circumference of the values in the diameter
column:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | (3.14159 * diameter) |
Parameter: New column name | 'circumference' |
Boolean
A true
or false
value.
Example: If the value in the order
column is more than 1,000,000, then the value in the bigOrder
column is true
.
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | IF(order > 1000000, true, false) |
Parameter: New column name | 'bigOrder' |
String
A string literal value is the baseline datatype. String literals must be enclosed in single quotes.
Example: Creates a column called, StringCol
containing the value myString
.
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | 'myString' |
Parameter: New column name | 'StringCol' |
Alteryx pattern
Designer Cloud supports a special syntax, which simplifies the generation of matching patterns for string values.
Patterns must be enclosed in accent marks ( `MyPattern`
). For more information onWrangle, seeText Matching.Example: Extracts up to 10 values from the MyData
column that match the basic pattern for social security numbers (XXX-XX-XXXX
):
Transformation Name |
|
---|---|
Parameter: Column to extract from | MyData |
Parameter: Option | Custom text or pattern |
Parameter: Text to extract | `%{3}-%{2}-%{4}` |
Parameter: Number of matches to extract | 10 |
Regular expression
Regular expressions are a common standard for defining matching patterns. Regex is a very powerful tool but can be easily misconfigured.
Regular expressions must be enclosed in slashes (/MyPattern/
).
Example: Deletes all two-digit numbers from the qty
column:
Transformation Name |
|
---|---|
Parameter: Column | qty |
Parameter: Find | /^\d$|^\d\d$/ |
Parameter: Replace with | '' |
Parameter: Match all occurrences | true |
Datetime
A valid date or time value that matches the requirements of the Datetime datatype.
Datetime values can be formatted with specific formatting strings. See DATEFORMAT Function.
Example: Generates a new column containing the values from the myDate
column reformatted in yyyymmdd
format:
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | DATEFORMAT(myDate, 'yyyymmdd') |
Array
A valid array of values matching the Array data type.
Example:
[0,1,2,3,4,5,6,7,8]
Example: Generates a column with the number of elements in the listed array (7
):
Transformation Name |
|
---|---|
Parameter: Formula type | Single row formula |
Parameter: Formula | ARRAYLEN('["red", "orange", "yellow", "green", "blue", "indigo", "violet"]') |
Object
A valid set of values matching the Object data type.
Example:
{"brand":"Subaru","model":"Impreza","color","green"}
Example: Generates separate columns for each of the specified keys in the object ( brand
, model
, color
), containing the corresponding value for each row:
Transformation Name |
|
---|---|
Parameter: Column | myCol |
Parameter: Paths to elements | 'brand','model','color' |
For more information on these data types, see Supported Data Types.
Interactions between Wrangle and the Application
As you build Wrangle steps in the Transform Builder, your syntax is validated for you. You cannot add steps containing invalid syntax.
Error messages are reported back to the application, so you can make immediate modifications to correct the issue.
Type-ahead support can provide guidance to the supported transforms, functions, and column references.
When you have entered a valid transform step, the results are previewed for you in the data grid.
This preview is generated by applying the transformation to the sample in the data grid.
Note
The generated output applies only to the values displayed in the data grid. The function is applied across the entire dataset only during job execution.
If the previewed transformation is invalid, the data grid is grayed out.
When you add the transformation to your recipe:
It is applied to the sample in the application, and the data grid is updated to the current state.
Column histograms are updated with new values and counts.
Column data types may be re-inferred for affected columns.
Making changes:
You can edit any transformation step in your recipe whenever needed.
When you edit a transformation step in your recipe, the context of the data grid is changed to display the state of your data up to the point of previewing the step you're editing.
All subsequent steps are still part of the recipe, but they are not applied to the sample yet.
You can insert recipe steps between existing steps.
When you delete a recipe step, the state remains at the point where the step was removed.
You can insert a new step if needed.
When you complete your edit, select the final step of the recipe, which displays the results of all of your transformation steps in the data grid. Your changes may cause some recipe steps to become invalid.
For more information on these areas of the Cloud Portal, see Transformer Page.
Transformation
A transformation is an action for which you can browse or search through the Transform Builder in the Transformer page. When specified and added to the recipe, these sometimes complex actions are rendered in the recipe as steps using the underlying transforms of the language.
Tip
Through transformations, Designer Cloud guides you through creation of more sophisticated steps that would be difficult to create in raw Wrangle.
For more information on the list of available transformations, see Transformation Reference.
For more information on creating transformation steps in the Transformer page, see Transform Builder.
Functions
A function is an action that is applied to a set of values as part of a transform step. Functions can apply to the values in a transform for specific data types, such as strings, or to types of transforms, such as aggregate and window function categories. A function cannot be applied to data without a transform.
Function input parameters
Below, function inputs are listed in increasing order of generality.
Note
A function cannot take a higher-order parameter input type without taking the lower parameter input types. For example, a function cannot take a nested function as an input if it does not accept a literal value, too.
Order | Parameter input type | Example |
---|---|---|
1 | literal | FUNCTION('my input') |
2 | column | FUNCTION(myColumnOfValues) |
3 | function | FUNCTION(SUM(MyCol)) |
Function categories
Function Category | Description |
---|---|
These functions are used to perform aggregation calculations on your data, such as sum, mean, and standard deviation. | |
Comparison functions enable evaluation between two data elements, which are typically nested (Object or Array) elements. | |
Perform computations on your data using a variety of math functions and numeric operators. | |
Calculate standard trigonometry functions as well as arc versions of them. | |
Use these functions to extract data from or perform operations on objects of Datetime data type. | |
Manipulate strings, including finding sub-strings within a string. | |
These functions are designed specifically to assist in wrangling nested data, such as Objects, Arrays, or JSON elements. | |
Use the Type functions to identify valid, missing, mismatched, and null values. | |
The Window functions enable you to perform calculations on relative windows of data within your dataset. | |
Miscellaneous functions that do not fit into the other categories |
Operator Categories
An operator is a single character that represents an arithmetic function. For example, the Plus sign (+
) represents the add function.
Operator Category | Description |
---|---|
and, or, and not operators | |
Add, subtract, multiply, and divide | |
Compare two values with greater than, equals, not equals, and less than operators | |
Use ternary operators to create if/then/else logic in your transforms. |
Transforms
A transform, or verb, is an action applied to rows or columns of your data. Transforms are the essential set of changes that you can apply to your dataset.
Note
Transforms are a part of the underlying language, which is not directly accessible to users. This content is maintained for reference purposes only. For more information on the user-accessible equivalent to transforms, see Transformation Reference.
Transforms are described in the Language Appendices. For more information, see Transforms.
Documentation
Documentation for Wrangle is also available through Designer Cloud. Select Resources menu > Documentation.