Skip to Content
DataFormula and Conditions

Formula and Conditions

Formulas and Conditional Judgments

In addition to being used directly by actions and components, data can also be processed through formulas and conditional logic.

Formulas

Formulas are functions used to calculate or transform data. Momen provides a variety of formulas for operations on text, numbers, arrays, time, and more.

Type Conversion

NameDescriptionExample
TO_TEXTConverts integers, decimals, JSONB, etc., to textOriginal data: {"message": "Hello World!"}'{"message": "Hello World!"}'
TO_INTEGERConverts text or decimals to integersOriginal data: -3.1415926-3
TO_DECIMALConverts text to decimalsOriginal data: "-3.1415926"-3.1415926
TEXT_TO_DATETIMEConverts text to datetimeOriginal data: "2025-02-21 14:36"2025-02-21T14:36:00.000+08:00
COMBINE_DATE_AND_TIMECombines date and time into datetimeDate: 2024-01-08, Time: 13:38:00.000+08:002024-01-08T13:38:00.000+08:00
EXTRACT_DATE_OR_TIMEExtracts date or time from datetime (timestamp)Datetime: 2024-01-08 13:38:00.000+08:00, Extract: Date → 2024-01-08

Text Processing

NameDescriptionExample
STRING_LENReturns the length of the text. All characters (including Chinese, letters, numbers, symbols) count as one.Text: "Hello World!"12
REPLACE_PARTReplaces part of the text with new text based on the specified position (first character is 0) and number of characters.Text: "Hello World!", Start: 1, Length: 4, New text: "ola""Hola World!"
REPLACE_TEXTFinds the specified text and replaces it with new text, based on the number of occurrences.Text: "Hello World!", Old: "o", New: "", Count: 1"Hell World"
FINDReturns the position of the first occurrence of the specified text. Returns -1 if not found.Text: "Hello World!", Find: "o"4
CONTAINChecks if the specified text exists, returns true or false.Text: "Hello World!", Find: "ello"true
SUBSTRINGExtracts a substring. Includes the start position but not the end; first character is 0.Text: "Hello World!", Start: 0, End: 5"Hello"
LEFTReturns a specified number of characters from the start of the text.Text: "Hello World!", Count: 5"Hello"
RIGHTReturns a specified number of characters from the end of the text.Text: "Hello World!", Count: 5"World"
LOWERConverts all letters in the text to lowercase.Text: "Hello World!""hello world!"
UPPERConverts all letters in the text to uppercase.Text: "Hello World!""HELLO WORLD!"
RANDOM_STRINGGenerates random text. (Random characters are generated on the frontend and are not recommended for secure scenarios such as coupon codes.)Min length: 5, Max length: 10, Lowercase: true, Uppercase: true, Numbers: true"seXr3aoRD"
SPLITSplits the text into an array using the specified separator.Text: "2024/01/08", Separator: "/"["2024", "01", "08"]

Mathematical Operations

NameDescriptionExample
+Addition5 + 1015
-Subtraction5 - 10-5
*Multiplication5 * 1050
/Division5 / 100.5
%Remainder after division, same sign as dividend-5 % 10-5
MINReturns the minimum value5, 105
MAXReturns the maximum value5, 1010
ROUND_UPRounds up to the nearest integer3.54
ROUND_DOWNRounds down to the nearest integer-3.5-4
INTRounds to the nearest integer-3.53
ABSReturns the absolute value-3.53.5
RANDOM_NUMBERReturns a random integer between specified numbers (not recommended for secure scenarios)Min: 1, Max: 106
POWERExponentiationBase: 2, Exponent: 38
DECIMAL_FORMATDecimal formatting (returns text if “Remove all trailing zeros” is selected)3.1415926, Precision: 2, Remove trailing: true3.14

Array Processing

NameDescriptionExample
GET_ITEMRetrieves an item from an array (index starts from 0)["2024", "01", "08"], Index: 1"01"
ARRAY_TO_ITEMRetrieves an item from an array (deprecated, use GET_ITEM)["2024", "01", "08"], Index: 1"01"
ARR_LENGets the length of the array["2024", "01", "08"]3
FIRSTReturns the first item of the array["2024", "01", "08"]"2024"
LASTReturns the last item of the array["2024", "01", "08"]"08"
RANDOM_ITEMReturns a random item from the array["2024", "01", "08"]"01"
SLICEExtracts a section of the array["2024", "01", "08"], Start: 1, Count: 2["01", "08"]
JOINJoins an array of text into a string["2024", "01", "08"], Separator: "-""2024-01-08"
INDEX_OFReturns the index of the first occurrence of the specified item["2024", "01", "08"], Item: "08"2

Time Operations

NameDescriptionExample
GET_DATE_TIMEGets a point in timeYear: 2024, Month: 1, Day: 8, Hour: 13, Minute: 14, Second: 02024-01-08T13:14:00.000+08:00
DELTAAdds or subtracts timeTime: 13:38:00.000+08:00, Add 1 hour 12 min14:50:00.000+08:00
DURATIONCalculates the interval between two points in timeStart: 2019-12-01, End: 2024-01-08, Unit: Year5
EXTRACTRetrieves a specified part of the timeTime: 13:38:00.000+08:00, Unit: Hour13
TO_DATETIMEConverts date and time into DateTime (timestamp)Date: 2024-01-08, Time: 13:38:00.000+08:002024-01-08T13:38:00.000+08:00
TO_DATE_TIMERetrieves the date or time from a DateTime (timestamp)DateTime: 2024-01-08 13:38:00.000+08:00, Extract: Date2024-01-08

Geographical Location

NameDescriptionExample
DISTANCECalculates the distance between two locations (meters, kilometers, or miles)[120.2934,30.3150], [120.2934,31.3150], km866
GET_VALUE_FROM_GEO_POINTRetrieves longitude or latitude from a geo point (latitude and longitude)[120.2934,30.3150], Type: Latitude30.3150

JSON Processing Methods

NameDescriptionExample
JSON_EXTRACT_PATHRetrieves data from JSON{"data": {"foo": "bar"}}, Path: data.foo"bar"

Conditions

Logical operations on data are used in Conditional View, Conditional Data, and conditional branches of Actionflow. For detailed usage, see the relevant documentation.

Formula and condition usage example

Last updated on