Monetize360
WorkflowsFunctionsSystem Functions

Calculate Expression

Perform calculations and formulas using your data

Calculate Expression

Perform calculations, formulas, and data transformations using your workflow data. Use this to compute values, combine fields, or transform data before using it in other steps.

Technical Name: ExpressionFunc

Properties

  • Execution Mode: SYNC
  • Type: NATIVE
  • Category: System Functions
  • Function ID: e4a7c2f1-9d83-4b5a-8c6e-f2d3e1a7b890

Input Schema

Required Parameters

ParameterTypeDescription
expressionsarrayList of MAPL expressions to evaluate

Optional Parameters

ParameterTypeDescription
variableVsValueMapobjectMap of variable names to values for evaluation
outputVariablesarrayList of variable names to include in output

[Image placeholder: Expression function configuration]

Input Example

{
  "expressions": [
    "total = price * quantity",
    "tax = total * 0.08",
    "grandTotal = total + tax",
    "discount = total > 100 ? 0.10 : 0.05"
  ],
  "variableVsValueMap": {
    "price": 25.00,
    "quantity": 5
  },
  "outputVariables": ["total", "tax", "grandTotal", "discount"]
}

Output Example

{
  "total": 125.00,
  "tax": 10.00,
  "grandTotal": 135.00,
  "discount": 0.10
}

MAPL Syntax

Arithmetic Operations

sum = a + b
difference = a - b
product = a * b
quotient = a / b
remainder = a % b

Comparison Operations

isEqual = a == b
isNotEqual = a != b
isGreater = a > b
isLess = a < b

Conditional Expressions

result = condition ? valueIfTrue : valueIfFalse
status = amount > 1000 ? "high" : "low"

[Image placeholder: MAPL syntax examples]

Use Cases

Price Calculations

Calculate pricing with discounts and tax:

{
  "expressions": [
    "subtotal = price * quantity",
    "discount = subtotal > 500 ? 0.15 : subtotal > 100 ? 0.10 : 0.05",
    "discountAmount = subtotal * discount",
    "afterDiscount = subtotal - discountAmount",
    "tax = afterDiscount * taxRate",
    "total = afterDiscount + tax"
  ],
  "variableVsValueMap": {
    "price": 50,
    "quantity": 12,
    "taxRate": 0.08
  }
}

Status Determination

Determine status based on multiple conditions:

{
  "expressions": [
    "isPremium = customerTier == 'premium'",
    "isHighValue = orderTotal > 1000",
    "qualifiesForBonus = isPremium && isHighValue",
    "bonusAmount = qualifiesForBonus ? orderTotal * 0.05 : 0"
  ],
  "variableVsValueMap": {
    "customerTier": "premium",
    "orderTotal": 1500
  }
}

[Image placeholder: Expression use cases]

Built-in Functions

Mathematical Functions

abs(x)           - Absolute value
ceil(x)          - Round up
floor(x)         - Round down
round(x)         - Round to nearest integer
sqrt(x)          - Square root
min(a, b, ...)   - Minimum value
max(a, b, ...)   - Maximum value

String Functions

concat(a, b)     - Concatenate strings
length(str)      - String length
upper(str)       - Convert to uppercase
lower(str)       - Convert to lowercase

[Image placeholder: Built-in functions reference]

Best Practices

  1. Clear Variable Names: Use descriptive names for clarity
  2. Break Complex Logic: Split complex calculations into multiple expressions
  3. Validate Inputs: Check for null or undefined values
  4. Test Edge Cases: Test with boundary values

Comparison with JavaScript

AspectExpression (MAPL)JavaScript
ComplexitySimple calculationsComplex logic
PerformanceFasterSlower
SyntaxFormula-likeFull programming language
Use CaseMath and logicData transformation

[Image placeholder: Expression vs JavaScript comparison]

[Image placeholder: Expression debugging workflow]