ℹ How to use Functions in Workflows

Mirjam Schuke
Mirjam Schuke Administrator
edited September 9 in Tips and tricks
Workflows

Workflows is the area in Data Studio where designer users tend to spend most of their time. For anyone new to it, imagine a data pipeline that manipulates one or more data sources through a number of stages and then does something with the results.

Whilst a Workflow is easy to build by connecting different steps together, it is most valuable to build this out for a process that needs to be run repeatedly. It can be helpful to plan a new workflow on paper to visualise the different steps, how they depend on each other and what the outcome should be.

Each step in the Workflow allows you to ‘Show step results’ i.e. what the data looks like up to that point. 

It is then possible to explore the data and manipulate it in the grid using either the action buttons or by right-clicking the column headers to check the data is as expected. 

Since most of the actions have equivalent Workflow steps, clicking ‘Add to Workflow’ will convert them into additional steps in the Workflow so that they become part of the data pipeline.

Some Workflow steps (or their equivalent Actions) use Functions, including the Filter, Split, Transform and Validate.

Functions

There are over 100 Functions that can be applied to a column of data, i.e. if a value equals A or B or C then return True else return False. Alternatively, if a number or date is greater than N return True. This can be used in a Split step to divide data and send it down different branches of a Workflow. A rule such as ‘ID should never be NULL’ in a Validate step is a Function but using another name in this context.

Anyone familiar with formulas in Excel or SQL functions will see many similarities with Data Studio Functions, for example a Transform converting each value in a column to lowercase:

Excel formula: =LOWER(A1)
SQL function: SELECT LCASE(column_name);
Data Studio function: LowerCase([c: column_name]) 

In Data Studio, Functions can be built using a simple drag and drop UI that is similar to Workflows, so you don't need to know how to write code, although it can be useful to edit the Function script in combination with the UI to be more efficient. The examples above are quite simple, but Functions can be connected to achieve more complex outcomes:  

A more complex Function you have built is often called a custom or advanced Function. This could exist only within the Workflow step/Action or if it is something that will be useful several times in many different Workflows then make it Re-usable and it will appear in the Function list and can be shared to other Spaces.

Find more detailed information about creating Workflows and Functions on our respective documentation pages.

Comments