Simple Data Transformations
On the top right corner of the datasheet, under more options, an option can be found to edit the datasheet schema. On clicking it, a panel appears on the right which displays metadata related to the columns. The columns can be duplicated and edited by clicking on the more option that is activated after choosing “Edit Schema”.
Upon duplicating a column, several options can be found to modify columns. Data can be extracted from existing columns to make new columns. Specific data type columns have relevant built in options for transformations. Additionally, custom expressions can be added to compute on existing column data.
An example has been described to illustrate the usage of this feature to extract the difference between two dates - SalesDate and current date.
Using Docube UI
- Navigate to the file and click on “Edit Datasheet Schema” from the more options on the top right corner of the screen.
- In a panel on the right, all columns and their metadata will be displayed. Click on the pencil icon to edit the columns.
- Duplicate a date column, SalesDate and expand the duplicate row. Click on the ‘+’ Symbol and select “Date Difference” from the options shown.
- Select “Today” in the argument named “Select Column” and provide the interval - days is what we choose for our example.
- Click on refresh to update the table.
Using SQL queries
- Select the SQL data and click on SQL Editor to navigate to the page where the SQL queries can be composed.
- Type the SQL query in the editor. In our case, it will be -
“ select
timestampdiff(WEEK,
EndDate
, now()) as date_diff
, *
from /Deployment - Test/Test-Data.csv
“
- Click on the play button to run the query.
- The updated table in accordance to the query can be seen.
- Preview the data and publish the sheet.