Compare Values

Depending on the data type, you can compare values in separate columns or single columns against fixed values.

Compare Numeric Values

You can use basic comparison operators to perform comparisons on your data. In this example, the compareCol column is generated as the evaluation of 3 < 6, which is true:

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula (3 < 6)
Parameter: New column name 'compareCol'

For more information, see Comparison Operators.

Compare Boolean Values

Boolean values can be true or false, so comparisons like the following can be applied to a Boolean set of values:

Transformation Name Edit column with formula
Parameter: Columns Attendance
Parameter: Formula IF(isSeated == true,true,Attendance)

In the above case, the value in Attendance is set to true if the value in the isSeated column is true. Otherwise, the current value in Attendance is used.

Compare Date Values

You can use the DATEDIF function to compare two date values, as in the following, which compares the number of days between startCol and endCol values:

NOTE: Both parameters of the DATEDIF function must be column references containing valid date values.

Transformation Name New formula
Parameter: Formula type Single row formula
Parameter: Formula DATEDIF(startCol, endCol, 'day')
Parameter: New column name 'DurationInDays'

See DATEDIF Function.

Compare String Values

For string values, you can use the string comparison functions to check how strings compare using Latin collation settings.

Tip: Any column can be converted to String data type to use these functions.

Available functions:

For more information on collation, see String Collation Rules.

You can also use the following functions to evaluate sub-strings within a string which can be compared to other values:

Was this page helpful? Let us know how we did:

Send feedback about...

Google Cloud Dataprep Documentation
Need help? Visit our support page.