Formulas and Functions
Use formulas in databinding, Conditional View, conditional data, and actions.
Formulas and conditional logic
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
| Name | Description | Example |
|---|---|---|
| TO_TEXT | Converts integers, decimals, boolean, or JSON to text | Original data: {"message": "Hello World!"} → '{"message": "Hello World!"}' |
| TEXT_TO_INTEGER | Converts text to integers | Original data: "-3.1415926" → -3 |
| TO_DECIMAL | Converts text to decimals | Original data: "-3.1415926" → -3.1415926 |
| TEXT_TO_DATETIME | Converts text to datetime | Original data: "2025-02-21 14:36" → 2025-02-21T14:36:00.000+08:00 |
| COMBINE_DATE_AND_TIME | Combines date and time into datetime | Date: 2024-01-08, Time: 13:38:00.000+08:00 → 2024-01-08T13:38:00.000+08:00 |
| EXTRACT_DATE_OR_TIME | Extracts date or time from datetime (timestamp) | Datetime: 2024-01-08 13:38:00.000+08:00, Extract: Date → 2024-01-08 |
Text Processing
| Name | Description | Example |
|---|---|---|
| TEXT_LEN | Returns the length of the text. All characters (including Chinese, letters, numbers, symbols) count as one. | Text: "Hello World!" → 12 |
| REPLACE_PART | Replaces 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_TEXT | Finds 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" |
| FIND | Returns the position of the first occurrence of the specified text. Returns -1 if not found. | Text: "Hello World!", Find: "o" → 4 |
| CONTAINS | Checks if the specified text exists, returns true or false. | Text: "Hello World!", Find: "ello" → true |
| SUB_TEXT | Extracts a substring. Includes the start position but not the end; first character is 0. | Text: "Hello World!", Start: 0, End: 5 → "Hello" |
| LEFT | Returns a specified number of characters from the start of the text. | Text: "Hello World!", Count: 5 → "Hello" |
| RIGHT | Returns a specified number of characters from the end of the text. | Text: "Hello World!", Count: 5 → "World" |
| LOWER | Converts all letters in the text to lowercase. | Text: "Hello World!" → "hello world!" |
| UPPER | Converts all letters in the text to uppercase. | Text: "Hello World!" → "HELLO WORLD!" |
| RANDOM_TEXT | Generates 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" |
| SPLIT | Splits the text into an array using the specified separator. | Text: "2024/01/08", Separator: "/" → ["2024", "01", "08"] |
| ENCODE_URL | Converts text string to URL standard format | Text: "https://docs.momen.app/data/formula/" → "https%3A%2F%2Fdocs.momen.app%2Fdata%2Fformula%2F" |
| DECODE_URL | Decodes a URL encoded by ENCODE_URL function | Text: "https%3A%2F%2Fdocs.momen.app%2Fdata%2Fformula%2F" → "https://docs.momen.app/data/formula/" |
| UUID | Randomly generates a string-type unique identifier | None → "550e8400-e29b-41d4-a716-446655440000" |
| TEXT_REPEAT | Repeats text a specified number of times | Text: "Yes", Count: 3 → "YesYesYes" |
| TRIM | Removes spaces from the beginning and end of text | Text: " dadada " → "dadada" |
| REGEX_EXTRACT | Extracts the first text segment that matches the regex | Text: "Phone number is 13940983244", Regex: \d{11} → "13940983244" |
| REGEX_EXTRACT_ALL | Returns all text segments that match the regex | Text: "Phone: 13940983244 and 13234322452", Regex: \d{11} → ["13940983244","13234322452"] |
| REGEX_MATCH | Determines if text contains content that matches the regex | Text: "13812345678", Regex: ^\d{11}$ → true |
| REGEX_REPLACE | Replaces parts of text that match the regex | Source text: "Phone number is 13812345678", Regex: \d{11}, Replace: "***********" → "Phone number is ***********" |
| TEXT_CONCAT | Concatenates multiple text values into one text. | Text 1: "Hello", Text 2: "World!" → "HelloWorld!" |
Mathematical Operations
| Name | Description | Example |
|---|---|---|
| + | Addition | 5 + 10 → 15 |
| - | Subtraction | 5 - 10 → -5 |
| * | Multiplication | 5 * 10 → 50 |
| / | Division | 5 / 10 → 0.5 |
| % | Remainder after division, same sign as dividend | -5 % 10 → -5 |
| MIN | Returns the minimum value | 5, 10 → 5 |
| MAX | Returns the maximum value | 5, 10 → 10 |
| ROUND_UP | Rounds up to the nearest integer | 3.5 → 4 |
| ROUND_DOWN | Rounds down to the nearest integer | -3.5 → -4 |
| INT | Rounds to the nearest integer | -3.5 → -3 |
| ABS | Returns the absolute value | -3.5 → 3.5 |
| RANDOM_NUMBER | Returns a random integer between specified numbers (not recommended for secure scenarios) | Min: 1, Max: 10 → 6 |
| POWER | Exponentiation | Base: 2, Exponent: 3 → 8 |
| FORMAT_DECIMAL | Decimal formatting (returns text if “Remove all trailing zeros” is selected) | 3.1415926, Precision: 2, Remove trailing: true → 3.14 |
| LOG | Returns the logarithm of a number with specified base | Number: 8, Base: 2 → 3 |
| FORMAT_NUMBER | Formats a number. Can be used for percentage, thousand separators, etc. | Number: 1, Format type: "percent", Decimal places: 2 → "100.00%" |
Array Processing
| Name | Description | Example |
|---|---|---|
| GET_ITEM | Retrieves an item from an array (index starts from 0) | ["2024", "01", "08"], Index: 1 → "01" |
| ARRAY_LENGTH | Gets the length of the array | ["2024", "01", "08"] → 3 |
| FIRST_ITEM | Returns the first item of the array | ["2024", "01", "08"] → "2024" |
| LAST_ITEM | Returns the last item of the array | ["2024", "01", "08"] → "08" |
| RANDOM_ITEM | Returns a random item from the array | ["2024", "01", "08"] → "01" |
| SLICE | Extracts a section of the array | ["2024", "01", "08"], Start: 1, Count: 2 → ["01", "08"] |
| JOIN | Joins an array of text into a string | ["2024", "01", "08"], Separator: "-" → "2024-01-08" |
| INDEX_OF | Returns the index of the first occurrence of the specified item | ["2024", "01", "08"], Item: "08" → 2 |
| SEQUENCE | Generates a number sequence within the specified range (inclusive of start, exclusive of end). | Start: 0, End: 10, Step: 2 → [0,2,4,6,8] |
| COALESCE | Returns the first “non-null” item in the array from left to right | Array: [null,1,3,2] → 1 |
| ARRAY_MAX | Returns the maximum item value in the array | Array: [1,2,3] → 3 |
| ARRAY_MIN | Returns the minimum item value in the array | Array: [1,2,3] → 1 |
| ARRAY_SUM | Sums the values of items in the array | Array: [1,2,3] → 6 |
| ARRAY_AVERAGE | Returns the average value of items in the array | Array: [1,2,3] → 2 |
| ARRAY_CONCAT | Merges two arrays into one array | Array1: [1,2,3,4,5], Array2: [2,3,4] → [1,2,3,4,5,2,3,4] |
| UNIQUE | Removes duplicate items from the array | Array: [1,2,5,4,5,2,3,4] → [1,2,5,4,3] |
| ARRAY_MAPPING | Transforms each element of an array and returns a new array | Original array: [1,2,3,4], New array item: Original array item * 10 → [10,20,30,40] |
| FILTER | Filters the array based on a condition and returns a new array | Original array: [1,2,3,4], Condition: Original array item > 2 → [3,4] |
Enum Processing
| Name | Description | Example |
|---|---|---|
| ENTRIES | Converts enum type to an array. | Enum: TaskStatus (with values: NOT_STARTED, INPROGRESS, COMPLETED) → [{"name": "NOT_STARTED"}, {"name": "INPROGRESS"}, {"name": "COMPLETED"}] |
Time Operations
| Name | Description | Example |
|---|---|---|
| GET_DATE_TIME | Gets a point in time | Year: 2024, Month: 1, Day: 8, Hour: 13, Minute: 14, Second: 0 → 2024-01-08T13:14:00.000+08:00 |
| DELTA | Adds or subtracts time | Time: 13:38:00.000+08:00, Add 1 hour 12 min → 14:50:00.000+08:00 |
| DURATION | Calculates the interval between two points in time | Start: 2019-12-01, End: 2024-01-08, Unit: Year → 5 |
| EXTRACT | Retrieves a specified part of the time. For day of week, outputs integers 0-6, where 0 represents Sunday | Time: 13:38:00.000+08:00, Unit: Hour → 13 |
| TO_DATETIME | Converts date and time into DateTime (timestamp) | Date: 2024-01-08, Time: 13:38:00.000+08:00 → 2024-01-08T13:38:00.000+08:00 |
| TO_DATE_TIME | Retrieves the date or time from a DateTime (timestamp) | DateTime: 2024-01-08 13:38:00.000+08:00, Extract: Date → 2024-01-08 |
| FORMAT_DATE_TIME | Formats a datetime with standard format placeholders. For formatting rules, please refer to Time Formatting | Datetime: 2025-12-19T14:00:00.000+08:00, Format: "MMM. Do, YYYY", Language: "en" → "Dec 19th, 2025" |
| TIME_AGO | Relative time formatting (returns relative time description from now). | Datetime: 2025-12-18T14:00:00.000+08:00, Language: "en", Hide suffix: true → "5 hours ago" |
| FORMAT_DURATION | Formats a given duration value into a readable text. | Duration: 1000000, Unit: "Milliseconds", Format: "m min s sec" → "16 min 40 sec" |
Geographical Location
| Name | Description | Example |
|---|---|---|
| DISTANCE | Calculates the distance between two locations (meters, kilometers, or miles) | [120.2934,30.3150], [120.2934,31.3150], km → 866 |
| GET_VALUE_FROM_GEO_POINT | Retrieves longitude or latitude from a geo point (latitude and longitude) | [120.2934,30.3150], Type: Latitude → 30.3150 |
| GENERATE_GEO_POINT | Creates a standard geographical location coordinate point (GeoJSON format). | Longitude: 120.1, Latitude: 30.3150 → {"type":"Point","coordinates":[120.1,30.3150]} |
JSON Processing Methods
| Name | Description | Example |
|---|---|---|
| JSON_EXTRACT_PATH | Retrieves data from JSON | {"data": {"foo": "bar"}}, Path: data.foo → "bar" |
Last updated on