New variables

Overview

To create a new variable, click + Create variable. New variables can be persisted in the output table, and also used in other parts of your transform – such as joins and filters. You can perform operations against existing variables using a wide array of methods that input different types of parameters.
For example, if we wanted to look at the ratio between total payments and billed charges for a given record, we could divide average_total_payments by average_estimated_submitted_costs:
Create an average_reimbursement variable using the Safe divide method
You can read more about new variable methods here.

Case method

A common method to create variables is a Case statement (or an 'if/else' statement), which allows you to specify one or more conditions to specify the values of the new variable.
For example, to create a boolean variable isInArizona, we would create a comparison which finds each row where the value for provider_state is AZ and sets the value of our new boolean variable to TRUE.
The Case method takes advantage of comparisons, which are used throughout Redivis transforms.

Cast method

Another common method to create variables is Cast, which allows you to convert variables of a given type to another type. This method is useful for creating variables of uniform type to work with in other methods, coercing numeric values from string typed variables, and many other applications.
For example, we can round our float-type average_reimbursement variable by casting it to an integer.
If the values in the input variable(s) can't be cast to the specified type, the transform will fail, unless you specify convert to null, which will set any un-cast-able values to null.

Format strings

Since there are a variety of formats to specify calendar and temporal data, it's often necessary to convert between temporal typed variables (of type Date, DateTime, or Time) and other string representations.
By using format strings – often in parseDate (to convert a string to a temporal variable) and formatDate (to convert a temporal variable to a string) – you can specify how various fields are encoded within your data and create new variables with the appropriate type.
For example, to convert dates of mm/dd/yy format (common in the U.S.; e.g. 03/22/89 ), we would specify the format string %m/%d/%y . For a DateTime displayed as Mon Oct 17 2016 17:32:56 , we would specify %a %b %d %Y %H:%M:%S
Below is a complete list of format elements and descriptions:
Format element
Description
%A
The full weekday name.
%a
The abbreviated weekday name.
%B
The full month name.
%b or %h
The abbreviated month name.
%C
The century (a year divided by 100 and truncated to an integer) as a decimal number (00-99).
%c
The date and time representation.
%D
The date in the format %m/%d/%y.
%d
The day of the month as a decimal number (01-31).
%e
The day of month as a decimal number (1-31); single digits are preceded by a space.
%F
The date in the format %Y-%m-%d.
%G
The ISO 8601 year with century as a decimal number. Each ISO year begins on the Monday before the first Thursday of the Gregorian calendar year. Note that %G and %Y may produce different results near Gregorian year boundaries, where the Gregorian year and ISO year can diverge.
%g
The ISO 8601 year without century as a decimal number (00-99). Each ISO year begins on the Monday before the first Thursday of the Gregorian calendar year. Note that %g and %y may produce different results near Gregorian year boundaries, where the Gregorian year and ISO year can diverge.
%H
The hour (24-hour clock) as a decimal number (00-23).
%I
The hour (12-hour clock) as a decimal number (01-12).
%j
The day of the year as a decimal number (001-366).
%k
The hour (24-hour clock) as a decimal number (0-23); single digits are preceded by a space.
%l
The hour (12-hour clock) as a decimal number (1-12); single digits are preceded by a space.
%M
The minute as a decimal number (00-59).
%m
The month as a decimal number (01-12).
%n
A newline character.
%P
Either am or pm.
%p
Either AM or PM.
%R
The time in the format %H:%M.
%r
The 12-hour clock time using AM/PM notation.
%S
The second as a decimal number (00-60).
%s
The number of seconds since 1970-01-01 00:00:00. Always overrides all other format elements, independent of where %s appears in the string. If multiple %s elements appear, then the last one takes precedence.
%T
The time in the format %H:%M:%S.
%t
A tab character.
%U
The week number of the year (Sunday as the first day of the week) as a decimal number (00-53).
%u
The weekday (Monday as the first day of the week) as a decimal number (1-7).
%V
The week number of the year (Monday as the first day of the week) as a decimal number (01-53). If the week containing January 1 has four or more days in the new year, then it is week 1; otherwise it is week 53 of the previous year, and the next week is week 1.
%W
The week number of the year (Monday as the first day of the week) as a decimal number (00-53).
%w
The weekday (Sunday as the first day of the week) as a decimal number (0-6).
%X
The time representation in HH:MM:SS format.
%x
The date representation in MM/DD/YY format.
%Y
The year with century as a decimal number.
%y
The year without century as a decimal number (00-99), with an optional leading zero. Can be mixed with %C. If %C is not specified, years 00-68 are 2000s, while years 69-99 are 1900s.
%%
A single % character.
%E#S
Seconds with # digits of fractional precision.
%E*S
Seconds with full fractional precision (a literal '*').
%E4Y
Four-character years (0001 ... 9999). Note that %Y produces as many characters as it takes to fully render the year.

Export as PDF
Copy link
On this page
Overview
Case method
Cast method
Format strings