Logic Composer
Formula
Calculate one value, or one list, from a block's inputs and data with a single expression.
A formula is the simplest logic block: one expression that turns inputs and data into one result. Despite the name it is not limited to arithmetic. A formula can build a text, work out a date, pick a value with If Condition or Switch, or filter a list, as long as the answer is a single value or a single list.
Use a formula when the same calculation is needed in more than one place, such as a quote total, an SLA due date or a customer’s display name, so it is defined once and tested once.
Build a formula
Section titled “Build a formula”- Create a logic block and choose the Formula card. See Create a logic block.
- Add inputs on the Input tab, and on the Data tab add any rows or queries the formula needs.
- On the Formula tab, Choose what it returns: pick the result type in the Type field above the expression. Turn on List of values to return a list.
- Write the formula: select Write formula and build the expression in the expression editor. It must result in the type you chose.
- Save, then select Run to test it.
Settings
Section titled “Settings”| Setting | What it does | Notes |
|---|---|---|
| Type | The type of the result. | Changing it later asks “Change the type?” and clears the formula, so you build it again. |
| List of values | Returns a list instead of one value. | Not available when the block is exposed as a Dataverse action. |
| Expression | The calculation. | One expression, built in the expression editor. |
How it behaves
Section titled “How it behaves”- The block has one output, named
result. Callers that use the block in an expression pickresult; flows read it from the step that called the block. - The expression is evaluated each time the block runs, after the precondition and the Data tab.
- Empty inputs follow the expression rules: an empty number counts as 0 in arithmetic and comparisons, and an empty Yes/No counts as No in And and Or. Check optional inputs with Null or First Non-Empty. See Empty values.
- Dividing two whole numbers gives a whole number, so
7 / 2is3. Make one side a Decimal Number (for example with To Decimal) to keep the fraction. Dividing by zero fails the run.
Examples
Section titled “Examples”Quote line total
Section titled “Quote line total”Inputs: Quantity (Whole Number), UnitPrice (Currency), DiscountPercent (Decimal Number)
Type: Currency
Quantity * UnitPrice - Quantity * UnitPrice * DiscountPercent / 100SLA due date for a case
Section titled “SLA due date for a case”Inputs: CreatedOn (Date and Time), Priority (Choice, Case Priority)
Type: Date and Time
AddBusinessDays(CreatedOn, Switch(Priority; High => 1; Normal => 3; else 5))Customer tier label
Section titled “Customer tier label”Inputs: AnnualRevenue (Currency)
Type: Text
If(AnnualRevenue ≥ 1000000, "Enterprise", If(AnnualRevenue ≥ 100000, "Mid-market", "SMB"))Contacts that can receive email (list)
Section titled “Contacts that can receive email (list)”Inputs: Contacts (Row: Contact with its email column, List of values on)
Type: Row (Contact), with List of values on.
Filter(Contacts, c, Not Null Or Empty String(c.emailaddress1))The block returns a list of contacts that a flow can loop over.
Related
Section titled “Related”- Expression language
- Calling logic blocks
- Decision table: when the answer comes from combinations of conditions
- Run and test