Articles in this section

How to use functions GreaterThan(), LessThan() and Equals() with number values

About this article

This article explains what the GreaterThan(), LessThan() and Equals() functions are that you can use with number values and provide examples of how they can be used with the binding syntax in smart templates.  

Prerequisites

 

 

 

What is the GreaterThan() function?

The GreaterThan() function can be used in combination with the IfElse() function and returns output based on the condition if the number value entered is greater than the number used in the expression.

 

GreaterThan() logic

Syntax {{IfElse(GreaterThan(Condition), TrueValue, FalseValue)}}
Input Condition
Output TrueValue/FalseValue

 

Example

Using the GreaterThan() function together with the IfElse() function. Depending on the value entered the output is 'Value is greater than 10' or 'Value is 10 or less':

Binding {{IfElse(GreaterThan(Form.Number, 10), "Value is greater than 10", "Value is 10 or less")}}
Input

Form.Number = "5"

Form.Number = "10"

Form.Number = "15"

Condition  False False True
Output  "Value is 10 or less" "Value is 10 or less" "Value is greater than 10"

 

 
  • The GreaterThan() function only works with numeric fields, so the field 'Form.Number' in the example is of Type 'Number'.

 

What is the LessThan() function?

The LessThan() function can be used in combination with the IfElse() function and returns output based on the condition if the number value entered is less than the number used in the expression.

 

LessThan() logic

Syntax {{IfElse(LessThan(Condition), TrueValue, FalseValue)}}
Input Condition
Output TrueValue/FalseValue

 

Example 1

Using the LessThan() function together with the IfElse() function. Depending on the value entered the output is 'Value is less than 10' or 'Value is 10 or greater':

Binding {{IfElse(LessThan(Form.Number, 10), "Value is less than 10", "Value is 10 or greater")}}
Input

Form.Number = "5"

Form.Number = "10"

Form.Number = "15"

Condition  True False False
Output  "Value is less than 10" "Value is 10 or greater" "Value is 10 or greater"

 

 
  • The LessThan() function only works with numeric fields, so the field 'Form.Number' in the example is of Type 'Number'.

 

Example 2

Using the LessThan() and GreaterThan() function together with the IfElse() and And() function. Depending on the value entered the visibility (e.g. of text/image) is set to visible or hidden:

Binding {{IfElse(And(GreaterThan(Form.Number, 10), LessThan(Form.Number, 20)), VisibilityType.Visible, VisibilityType.Hidden)}}
Input

Form.Number = "10"

Form.Number = "15"

Form.Number = "20"

Condition  False True False
Output  Hidden text/image Visible text/image Hidden text/image

 

What is the Equals() function?

The Equals() function can be used in combination with the IfElse() function and returns output based on the condition if the number value entered is equal to the number used in the expression.

 

Equals() logic

Syntax {{IfElse(Equals(Condition), TrueValue, FalseValue)}}
Input Condition
Output TrueValue/FalseValue

 

Example

Using the Equals() function together with the IfElse() function. Depending on the value entered the output is 'Perfect score' or 'Please try again':

Binding {{IfElse(Equals(Form.Number, 10), "Perfect score", "Please try again")}}
Input

Form.Number = "5"

Form.Number = "10"

Form.Number = "15"

Condition  False True False
Output  "Please try again" "Perfect score" "Please try again"

 

 
  • The Equals() function works with both numeric fields and text fields. In the example above the field 'Form.Number' is of Type 'Number', but you can also use the Equals() function with a field of Type 'Text'. In that case you need to put quotes around the value like this:

    {{IfElse(Equals(Form.Number, "10"), "Perfect score", "Please try again")}}

  • If the Equals() function is used with numbers, it's recommended to use fields of Type 'Number' instead of 'Text'.

 

Related articles

 

 

number operators equals number values lessthan calculate greaterthan numeric values
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Article is closed for comments.