Formula basics
With dozens of built-in formulas, Fundamento offers you endless possibilities in processing your data. You can add formulas directly to the Documents, to Table columns, to Button blocks, to automations, and more.
For example, to help with generating invoices, you could create Formula that extracts
your customers initials from their full name, combines initials with the date of sale
and generates invoice number:
Illustration of calculating “Invoice No” field based on other fields in the row.
Where formulas can be used
Formulas can be used in following places:
- In Table, as a Formula column type.
- In Document, as a Button block type action.
- In Table, as a Button column type action.
- In a Webtrigger automation action.
Creating formula
To create a Formula column type:
- While visiting Table in edit mode, click column header and then click on the
PROPERTY TYPE
- Select
Formula
- Again click column header and then click on the
Edit formula
- Formula editor will appear, where you can input your formula:
Formula syntax
The Formula syntax is a little bit like in Excel, you will use a lot of parentheses:
Upper("this is awesome")
This is called wrapping. Things inside of parentheses can be viewed as one statement, or one sentence. Fundamento is going to look at that one statement and evaluate it as a whole. In lengthy formulas, parentheses will help note where one statement ends and the next begins.
Additionally, just like in math problems, you’ll use parentheses to separate multiple AND and OR functions so that all of your calculations happen in the right order. Fundamento will calculate anything inside of a parentheses first:
(2*2)/(4+4) = .5
In the example above, it will execute 2*2 and 4+4 before doing the division.
In the same way, use parentheses to specify how multiple AND or OR functions should be grouped. By default, the formula applies the logic from left to right in the order that it appears. If you want to specify a specific order, just use parentheses.
Actions
Majority of built-in functions are simple “get input produce output” idempotent functions
expected to yield the same results for the same input. This is not true for ACTION
type
functions. Executing “action” function will have a side effect in Fundamento, for example
it might add a new row to an existing Table. “Action” functions typically do not return
value and their primary usage is for Button block type.
Operators
Fundamento understands following built-in operators:
+
,-
,*
,/
- mathematical operators, additionally+
applied to strings concatenates them>
,>=
,<
,<=
,==
,!=
- logical operators
Strings
Strings are represented with literals surrounded with "
(double quotation mark).
Fundamento doesn’t honor single quotation mark - surrounding literals with '
will lead
to invalid formulas.Escaping "
in literal is done with \"
characters.
CurrentValue
Some built-in functions are meant to operate on collection of items. Notable examples of
such functions are ForEach
, Filter
, All
, Any
. As one of arguments these functions
require criteria (or expression) that will be applied to each item from the input collection.
To reference current item these criteria formulas can use CurrentValue
, for example:
Filter(List(1, 2, 3, 3, 3, 4), CurrentValue > 3)
Context variables
In some executions contexts Formulas might have access to additional data. To reference that additional data use square brackets notation, for example:
AddRow("Incoming alerts", "Message", [WebhookBody])
Popular formulas
There are formulas in the Fundamento you will use often. Let’s introduce them briefly.
Filter
You’ll use the Filter formula when you want to look at part of a Table to answer a question. The criteria for this formula can be as simple or as complex as you need.
The basic structure of Filter is:
Filter(Table("table you want to look at"), "criteria matching the part you're interested in")
CurrentRow
In typical spread sheet (like Google Sheets), the smallest unit is a cell. Since Fundamento tables are database at heart, the smallest unit is a row. Working with rows, you’re able to access all of the contextual details for each value (aka columns or attributes of the row).
For example, initial extractions might look like:
First(CurrentRow("First Name")) + First(CurrentRow("Last Name"))
If
The If formula allows you to handle if/then logic. The basic structure of the If() formula is as follows:
If(Condition, "What you want to happen if this condition is true", "What you want to happen if this condition is false")
A full list of the built-ins functions that are available in formulas is available here.