The 'Data transformation**'** tab

The purpose of the 'Data transformation' tab is to allow the user full flexibility in terms of creating completely custom reports that combine, aggregate and present data from multiple data source inputs in a way that is tailor made for each customer.

The 'Data transformation' allows the user to input custom Javascript code that takes the raw data from the data source, and then transforms it according to the code added to the 'Code Editor'.

To enable the use of a custom transformation function, you first have to activate the tab. Do so by clicking the switch toggle in the tab bar:

The 'Data transformation' tab in its enabled state

The 'Data transformation' tab in its enabled state

There are three main components of the 'Data transformation' tab:

Input preview

In the 'Input preview' tab, you can preview exactly what the input data looks like, to more easily write custom-made transformation code.

The format of the input data is as follows:

  1. Each data source input returns an object on the following format:

    type DataSourceInputReturn = {
    	headers: String[]; // An array of strings, where each element represents one column in the final report
    	data: (String | Number)[][]; // An array of arrays, where the outer array represents all of the rows, and each inner array contains all the elements for one row. The indicies correspond to the header indicies, i.e., data[0][0] is the value of the first row's first column
    	sheetName?: String; // The name of the sheet in an Excel report - optional
    	dataSourceInputId: String; // The id of the data source input that generated the return
    	isObjects: Boolean; // Boolean indicating whether the return contains an object export or not
    };
    
  2. All data sources inputs are elements in an array

    type DataSourceReturn = DataSourceInputReturn[];
    

<aside> 💡 Note that the input data will always be an array, even if only one data source input is being used

</aside>

To run the Input Preview, either press the 'Generate preview data now' button in the tab pane's empty state, or press the reload button in the tab bar itself:

Input Preview tab's empty state - press the 'Generate preview data now' button to populate the input preview

Input Preview tab's empty state - press the 'Generate preview data now' button to populate the input preview

To update the input preview, click the refresh button in the tab bar

To update the input preview, click the refresh button in the tab bar

Code Editor

The 'Code Editor' tab provides an interface to fully customize the content of the report the workflow generates.