**Contents:**

=20

=20
=20
- =20
- Usage =20
- Examples=20
- =20
- Less Than (or Equa= l To) =20
- Greater Than (o= r Equal To) =20
- Equal to =20
- Not Equal to =20

=20

=20 Comparison operators enable you to compare values in the left-hand s= ide of an expression to the values in the right-hand side of an expression.

=20

(left-hand= side) (operator) (right-hand side)=20

These evaluations result in a Boolean `true`

or ```
false result and can be used as the basis for determining whether the actio=
n of transform is executed on the row or column of data. The following oper=
ators are supported:
```

```
=20
=20
=20
=20
=20
=20
```
Operator Name
Symbol
Example Expression
Output
Notes
less than
`<`

`3 < 6`

`true`

less than or equal to
`<=3D`

`6 <=3D 5`

`false`

The following operator generates a=
n error: `=3D<`

greater than
>
`3 > 6`

`false`

greater than or equal to
>=3D
`6 >=3D 5`

`true`

The following operator=
generates an error: `=3D>`

equal to
=3D=3D
`4 =3D=3D 4`

`true`

For this comparison operator=
, you must use two equals signs, or an error is generated.
not equal to
`<>`

or=

!=3D

4 <> 4
`false`

Both operators are suppor=
ted.

The following operator generates an er=
ror: `=3D!`

The above examples apply to integer values only. Below, you can review h=
ow the comparison operators apply to different data types.

## Usage

Comparison operators are used to determine the condition of a set of dat=
a. Typically, they are applied in evaluations of values or rows.

For example, your dataset is the following:

city
San Francisco
Los Angeles
Chicago
New York

You could use the following transform to flag all rows whose ```
city<=
/code> value equals
````San Francisco`

:

```
=20
```derive type:single value:(city =3D=
=3D 'San Francisco')

Your output looks like the following:

=20
=20
=20
city
column1
San Francisco
true
Los Angeles
false
Chicago
false
New York
false

You can optionally combine the above with an `IF`

function, w=
hich enables you to write values for `true`

or `false outcomes:`

```
=20
```derive type:single value:IF(city =3D=
=3D 'San Francisco', 'Home of the Giants!', 'Some other team') as:'Baseball=
Team'

Note that the optional `as:`

clause can be used to rename the=
generated columns. See Derive T=
ransform.

city
BaseballTeam
San Francisco
Home of the Giants!
Los Angeles
Some other team
Chicago
Some other team
New York
Some other team

## Examples=

**Tip:** For additional examples, see Common Tasks.

**NOTE: **When a comparison is applied to a set of values, =
the type of data of each source value is re-inferred to match any literal v=
alues used on the other side of the expression. This method allows for more=
powerful comparisons.

In the following examples, values taken from the `MySource`

c=
olumn are re-typed to match the inferred data type of the other side of the=
comparison.

### Less Than (or Equal To)<=
/h3>
=20
=20
=20
=20
=20
Column Type
Example Transform
Output
Notes
Integer
=20
derive type:single value:(MySource &=
lt; 5)

`true`

for all values in `MySource`

that are less=
than 5.
- Otherwise,
`false`

.

Decimal
=20
keep row:(MySource <=3D 2.5)

Retains all rows in the dataset where the value =
in the `MySource`

column is less than or equal to 2.5.
Datetime
=20
keep row:(Date <=3D DATE(2009,12,31))

Retains all rows whose `Date`

column =
value is less than or equal to `12/31/2009`

.
You can also use the ```
DATEDIF=
```

function to generate the number of days difference between t=
wo date values. Then, you can compare this difference to another value. See=
DATEDIF Function.
String (and all other data types)
=20
derive type:single value:(LEN(MySour=
ce) < 5))

`true`

for any string value in the `MySource`

col=
umn whose length is less than 5 characters.
- Otherwise,
`false`

- See LEN Function.

- For comparison purposes, all data types not previously listed in this t=
able behave like strings.
- Since strings are non-numeric value, a function must be applied to stri=
ng data to render a comparison.

### Greater Than (or Equa=
l To)

See previous section.

### Equal to

=20
=20
=20
=20
=20
Column Type
Example Transform
Output
Notes
Integer
=20
derive type:single value:(MySource =
=3D=3D 5)

`true`

for all values in the `MySource`

column th=
at are 5.
- Otherwise,
`false`

.

If the source column contains Decima=
l values and the right-hand side is an integer value, the Deci=
mal values that are also integers can match in the comparison (e.g. =
`2.0 =3D=3D 2`

).
Decimal
=20
keep row:(MySource =3D=3D 2.5)

Retains all rows in the dataset where the value =
in the `MySource`

column is exactly 2.5.
If the source column contains integers and the r=
ight-hand side is a Decimal type value, integer values are rou=
nded for comparison.
Datetime
=20
keep row:(Date =3D=3D DATE(2016,12,25))

Retains all rows whose ```
Date<=
/code> column value is equal to
````12/25/2016`

.

String (and all other data types)
=20
keep row:(LEN(MySource) =3D=3D 5))

Retains all rows in the dataset where the length=
of the string value in the `MySource`

column is 5 characters.
- For comparison purposes, all data types not previously listed in this t=
able behave like strings.
- Since strings are non-numeric value, a function must be applied to stri=
ng data to render a comparison.

### Not Equal to

=20
=20
=20
=20
=20
Column Type
Example Transform
Output
Notes
Integer
=20
derive type:single value:(MySource &=
lt;> 5)

`true`

for all values in the `MySource`

column th=
at are not 5.
- Otherwise,
`false`

.

If the source column contains Decima=
l values and the right-hand side is an integer value, the Deci=
mal values that are also integers can match in the comparison (e.g. =
`2.0 =3D=3D 2`

).
Decimal
=20
keep row:(MySource <> 2.5)

Retains all rows in the dataset where the =
value in the `MySource`

column is not 2.5.=
If the source column contains integers and=
the right-hand side is a Decimal type value, integer values a=
re rounded for comparison.
Datetime
=20
keep row:(Date <> DATE(2016,4,15))

Retains all rows in the dataset where the ```
=
Date
```

value does not equal 4/15/2016.
String (and all other data types)
=20
keep row:(LEN(MySource) <> 5))

Retains all rows in the dataset where the =
length of the string value in the `MySource`

colu=
mn is not 5 characters.
- For comparison purposes, all data types not previously listed in this t=
able behave like strings.
- Since strings are non-numeric value, a function must be applied to stri=
ng data to render a comparison.

=20

```
------=_Part_77027_769914334.1611723475606--
```