DataChain formulas

Available in Logo GenericsData GenericsData & Logo HandleData HandleData

Formulas can be used to carry out more or less complex processing on datasets at different strategic levels in the value chain.

The unit functions available in DataChain allow you to create formulas of varying degrees of complexity.

Summary

  • Formulas can be used in Business Entities, DataBlocks and HandleData data sources.

  • The Formulas manager is used to create formulas from one or more unit functions.

  • Each unit function has one or more arguments.

  • The return value of a function can be of different types (list, value, boolean, …​)

  • All formulas return null if an error is encountered.

  • Formulas and unit functions can be nested to create complex formulas.

  • Formulas added to the formula catalogue can be reused from other elements and other projects

  • Formulas in the catalogue can be shared so that they are visible and usable by all users.

Formulas manager

Formulas can be applied to Business Entities, DataBlocks and data sources selected in the various HandleData visualisations (Graphs, Tables, etc.).

The formula manager is used to build and define formulas to be applied to data sets.

You can create new formulas or use those in the formula catalogue.

Presentation of the formula manager*Presentation of the *formulas manager.

image::formulas/formulas-manager.svg [Formulas screen]

1 Existing formulas in working context (1) + 2 Formulas screen 2 Activate or deactivate a formula (2)
3 Edit formula in list
4 Duplicate formula in list
5 Remove formula from list
6 Name of the formula selected or being created (Mandatory)
7 Formula description
8 Formula entry zone
9 Copies the formula currently being edited
10 Paste the formula previously copied
11 Opens the Formula Catalogue
12 Add the current formula to the formula catalogue
13 Display the formula as a tree
14 Click to create formula
15 Deletes all the formulas applied to the element or step in the DataBlock. 16 Closes the formula manager

(1) The notion of context refers to the page from which the Manager is opened. For example, if a Formula is added from a DataBlock step, the formulas presented in the list are those for the current step. (2) If a formula is inactive, then the column is still present in the table of values but the values are set to Null.

Building a formula

Each function expects one or more arguments.
The type of argument expected may be limited depending on the function.

Type of expected input value

Function prefix Type of input argument str.

String of characters

Numeric

Numeric

Date

Date

Boolean

Boolean

Boolean

URL address

Geographic

Geographic

List

Lists

Listings

Numeric

dc.,words., bin., file., http.

DataChain specific

To create a new formula, click on the New formula button, then enter a label and a description.
Then select the formula entry zone.

Building a formula image::ROOT:formulas-entry.svg[Enter functions]

Several functions are proposed from the list.
You can select and add formulas using the keyboard or mouse.

The functions are grouped by the type of argument expected as input. Start typing the formula prefix to refine the list.

1 Input zone
2 Search zone for a function
3 Available functions
4 Formula catalogue
5 Click to validate formula
6 Click to empty the formula input box
7 Cancels changes to the formula (editing only)

Defining function arguments

Every function has one or more arguments which must be defined.
The value that an argument can take can be of different kinds

  • a direct input of information

  • a column available in the source

  • a formula

  • a unit function

  • a value chosen from a closed list, proposed by DataChain

Some arguments expect a specific type of value.
For example

num.sinus(argument)

argument must be of numeric type (Integer, BigInteger, Decimal…​).

In this case, the lists of functions, formulas or available values will only contain elements that match the expected type.

You can use the mouse or keyboard to position yourself at the argument(s) to be defined.

Example of entering a formula image::formulas-creation.svg [Formulas Creation]

1 Name of the + function In the example of the str.split function, 2 arguments are required +. 2 Argument (1)
In the example, the column COMMON.
3 Separator
In the example, the hyphen in the 6 -
4 Displays formula in tree view
5 Details of the formula and expected arguments

(1) The list of elements depends on the type of attribute. For example, if the attribute is of type Integer, then elements of type Integer will be proposed and accepted.

It is possible to assign a formula from the catalogue as an argument to a formula.

Formula add to function

In the function argument 1 , click on Icon catalogue and select the formula you want to insert.

When the formula is complete, click on Validate 6.

To reset all the elements (label, function, description, etc.) of the formula, click on Empty.

To add the formula to the catalogue, click on the icon Catalogue icon.

Interpreting the output value of a formula

The value returned by a formula depends entirely on the function(s) it contains.
The list of formulas details the type of value returned as output.

If there is a type inconsistency in the arguments, the output value will always be null.

Formula catalogue

Each formula can be added to the catalogue for reuse.
The user who adds a formula to the catalogue becomes its owner.
The formula can be shared or not.

Shared formula
The formula can be used, duplicated and exported by all users from all projects, even if they were created from a private Project. + Only the owner can modify and delete it. Only the owner can modify or delete it.

Non-shared formulas
Only its owner can view, modify and use it, from any Project in which they are a member.

Display the list of formulas in the catalogue

To display all the formulas in the catalogue select GenericsData  Miscellaneous  Formulas catalogue.

Formulas catalogue page

To add a new formula from the catalogue, click New then New formula.
Create your formula and fill in the metadata, then click on Validate.

To share the formula with other users, set the share button to ON.

Add a formula to the Catalogue

You can add a formula to the Catalogue from the Formula Manager, opened from an element (a DataBlock, for example).

Click on Catalogue icon then fill in the formula’s metadata and whether it should be shared, and click on Save.

add to catalogue

Adding a formula to the catalogue

When adding a formula to the catalogue, the column references of the current element are replaced by a wildcard (/?/).
The values of other arguments that do not refer to a column in the current data block are retained.

Apply a formula from the Catalogue

Open the Formula Manager from the element page, then click on New formula > Catalogue icon.

Description of the screen for adding a catalogue formula * Catalogue icon.

  • 1 Select to display only the formulas of the current user

  • 2 Select formula

  • 3 Area detailing the selected formula

  • 4 Cancels current changes and closes the Catalogue

  • 5 Import or export a formula

  • 6 Delete formula from catalogue

  • 7 Enable formula sharing (if you are the owner)

Click on Assign * 8 to close the popup and return to the formula creation page.

To assign a formula from the catalogue to an attribute of a current formula, position the selector at the function argument 1 and click on Catalogue icon.

Formula add to formula