# LESSTHANEQUAL Function

Returns `true` if the first argument is less than or equal to the second argument. Equivalent to the `<=` operator.
• Each argument can be a literal Integer or Decimal number, a function returning a number, or a reference to a column containing numbers.

Since the function returns a Boolean value, it can be used as a function or a conditional.

NOTE: Within an expression, you might choose to use the corresponding operator, instead of this function. For more information, see Comparison Operators.

Wrangle vs. SQL: This function is part of Wrangle, a proprietary data transformation language. Wrangle is not SQL. For more information, see Wrangle Language.

## Basic Usage

`lessthanequal(myValue, maxLimit)`

Output: Returns `true` when the the `myValue` column is less than or equal to the value in `maxLimit`.

## Syntax and Arguments

`lessthanequal(value1, value2)`

ArgumentRequired?Data TypeDescription
value1YstringThe first value. This can be a number, a function returning a number, or a column containing numbers.
value2YstringThe second value. This can be a number, a function returning a number, or a column containing numbers.

### value1, value2

Names of the column, expressions, or literals to compare.

• Missing values generate missing string results.

Usage Notes:

Required?Data TypeExample Value
YesColumn reference, function, or numeric or String value`myColumn`

## Examples

Tip: For additional examples, see How-to Guides.

### Example - Basic Comparison Functions

This simple example demonstrate available comparison functions:

Source:

colAcolB
111
210
39
48
57
66
75
84
93
102
111

Transformation:

Add the following transforms to your recipe, one for each comparison function:

Transformation Name `New formula` `Single row formula` `LESSTHAN(colA, colB)` `'lt'`

Transformation Name `New formula` `Single row formula` `LESSTHANEQUAL(colA, colB)` `'lte'`

Transformation Name `New formula` `Single row formula` `EQUAL(colA, colB)` `'eq'`

Transformation Name `New formula` `Single row formula` `NOTEQUAL(colA, colB)` `'neq'`

Transformation Name `New formula` `Single row formula` `GREATERTHAN(colA, colB)` `'gt'`

Transformation Name `New formula` `Single row formula` `GREATERTHANEQUAL(colA, colB)` `'gte'`

Results:

colAcolBgtegtneqeqltelt
111falsefalsetruefalsetruetrue
210falsefalsetruefalsetruetrue
39falsefalsetruefalsetruetrue
48falsefalsetruefalsetruetrue
57falsefalsetruefalsetruetrue
66truefalsefalsetruetruefalse
75truetruetruefalsefalsefalse
84truetruetruefalsefalsefalse
93truetruetruefalsefalsefalse
102truetruetruefalsefalsefalse
111truetruetruefalsefalsefalse

### Example - Using Comparisons to Test Ranges

In the town of Circleville, citizens are allowed to maintain a single crop circle in their backyard, as long as it confirms to the town regulations. Below is some data on the size of crop circles in town, with a separate entry for each home. Limits are displayed in the adjacent columns, with the `inclusive` columns indicating whether the minimum or maximum values are inclusive.

Tip: As part of this exercise, you can see how to you can extend your recipe to perform some simple financial analysis of the data.

Source:

House155.510Y25N
House21210Y25N
House314.2510Y25N
House43.510Y25N
House52710Y25N

Transformation:

After the data is loaded into the Transformer page, you can begin comparing column values:

Transformation Name `New formula` `Single row formula` `LESSTHANEQUAL(Radius_ft,minRadius_ft)` `'tooSmall'`

While accurate, the above transform does not account for the `minInclusive` value, which may be changed as part of your steps. Instead, you can delete the previous transform and use the following, which factors in the other column:

Transformation Name `New formula` `Single row formula` `IF(minInclusive == 'Y',LESSTHANEQUAL(Radius_ft,minRadius_ft),LESSTHAN(Radius_ft,minRadius_ft))` `'tooSmall'`

In this case, the `IF` function tests whether the minimum value is inclusive (values of `10` are allowed). If so, the `LESSTHANEQUAL` function is applied. Otherwise, the `LESSTHAN` function is applied. For the maximum limit, the following step applies:

Transformation Name `New formula` `Single row formula` `IF(maxInclusive == 'Y', GREATERTHANEQUAL(Radius_ft,maxRadius_ft),GREATERTHAN(Radius_ft,maxRadius_ft))` `'tooBig'`

Now, you can do some analysis of this data. First, you can insert a column containing the amount of the fine per foot above the maximum or below the minimum. Before the first `derive` command, insert the following, which is the fine (`\$15.00`) for each foot above or below the limits:

Transformation Name `New formula` `Single row formula` `15` `'fineDollarsPerFt'`

At the end of the recipe, add the following new line, which calculates the fine for crop circles that are too small:

Transformation Name `New formula` `Single row formula` `IF(tooSmall == 'true', (minRadius_ft - Radius_ft) * fineDollarsPerFt, 0.0)` `'fine_Dollars'`

The above captures the too-small violations. To also capture the too-big violations, change the above to the following:

Transformation Name `New formula` `Single row formula` `IF(tooSmall == 'true', (minRadius_ft - Radius_ft) * fineDollarsPerFt, if(tooBig == 'true', (Radius_ft - maxRadius_ft) * fineDollarsPerFt, '0.0'))` `'fine_Dollars'`

In place of the original "false" expression (`0.0`), the above adds the test for the too-big values, so that all fines are included in a single column. You can reformat the `fine_Dollars` column to be in dollar format:

Transformation Name `Edit column with formula` `fine_Dollars` `NUMFORMAT(fine_Dollars, '\$###.00')`

Results:

After you delete the columns used in the calculation and move the remaining ones, you should end up with a dataset similar to the following:

House11555.510Y25N\$457.50
House2151210Y25N\$0.00
House31514.2510Y25N\$0.00
House4153.510Y25N\$97.50
House5152710Y25N\$30.00

Now that you have created all of the computations for generating these values, you can change values for `minRadius_ft` , `maxRadius_ft` , and `fineDollarsPerFt` to analyze the resulting fine revenue. Before or after the transform where you set the value for `fineDollarsPerFt`, you can insert something like the following:

Transformation Name `Edit column with formula` `minRadius_ft` `'12.5'`

After the step is added, select the last line in the recipe. Then, you can see how the values in the `fineDollars` column have been updated.

[{ "type": "thumb-down", "id": "hardToUnderstand", "label":"Hard to understand" },{ "type": "thumb-down", "id": "incorrectInformationOrSampleCode", "label":"Incorrect information or sample code" },{ "type": "thumb-down", "id": "missingTheInformationSamplesINeed", "label":"Missing the information/samples I need" },{ "type": "thumb-down", "id": "otherDown", "label":"Other" }]
[{ "type": "thumb-up", "id": "easyToUnderstand", "label":"Easy to understand" },{ "type": "thumb-up", "id": "solvedMyProblem", "label":"Solved my problem" },{ "type": "thumb-up", "id": "otherUp", "label":"Other" }]