There are many scenarios in which it is needed to perform more advanced functions and logical statements that require a little bit more of coding. For these cases, we have the Functions node! Using the Functions node you can perform:

  • Number Functions: These are the mathematical/ arithmetical calculations in which you can add, subtract, divide, or multiply numeric fields. It is also possible returning the minimum (LEAST) or maximum (GREATEST) value for a specific field. Furthermore, you can also calculate the Ceil, Floor, Round, or the absolute value of specific fields.
    • The floor value is a type of rounded value that gives you the nearest integer down. For example, the floor of 5.21 is 5.
    • The ceiling value is a type of rounded value that gives you the nearest integer up. For example, the ceiling of 5.21 is 6.
    • The round function returns the value of a number rounded to the nearest integer which can be either up or down. For example, the rounded value of 5.21 is 5.
    • The absolute value often denoted as |x|, is the distance of a number from 0. For instance, the absolute value of 5 is 5, and the absolute value of -5 is also 5.
  • Text Functions: These are functions used to manipulate text, or string fields. A few examples are trimming text, changing it into upper or lower cases, replacing text, splitting, and so on.
  • Boolean Functions: These are functions that follow certain binary conditions and returns either True or False. You can use with the other function types above to create very powerful and complex queries. A few example of boolean functions or operators are AND, OR, NOT, GREATER_THAN, LESS_THAN, CONTAINS, etc.
  • Date + Time Functions: Finally, there are the date and time related functions. These allow you to subtract dates, truncate date values and cast data types to convert it to a datetime or timestamp, for example.

Another usage for the node is to join columns together or add extra text to a column, displaying them in a new column or overwrite an existing column. For example, you could create a new column "full_name" that concats the columns "name" and "surname". Likewise, you may just create a new column with the same values in every row by just typing the text in between quotation marks.

 

Note: In order to use the Model feature you already should have already imported data sources into Y42.

 

Adding the Functions Node to Your Model

  1. In the Model tab, click Add... Name your new data model and choose a privacy level.
  2. Create at least one input table by dragging and dropping the Input field into your data model structure. Choose a data table by clicking on it, then click Save.
  3. Drag and drop a Functions node close to the Input field. They will automatically connect. Alternatively, you can manually link the nodes by dragging and dropping a line:

Screenshot_2021-09-15_at_12.58.41.png

 

Setting Up Your Functions Node

  1. Click on the Functions node to apply the node settings. On this node, besides of the interface for setting up your node, or creating your functions, you have access to the documentation for each available function on the right side.

Screenshot_2021-09-15_at_13.09.11.png

  1. You can choose to create a new column by typing it into the Target Column box or overwrite an existing column by selecting it from the menu.
  2. Choose the function or the combination of functions you want to apply in your data calling the columns by using the @ symbol.
  3. When you're done, you can check the transformation by clicking Output. If you're satisfied, click Save.

Once you're done extracting the minimum or maximum of your columns, you can either perform further transformations or, if you want to export the new data table, click Commit Model.

Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.