- 18 May 2022
- 2 Minutes to read
Adding a Custom Column
- Updated on 18 May 2022
- 2 Minutes to read
Sisense makes it easy for you to add new columns to existing tables in both ElastiCube and live models. This can be useful if you need to combine data from different existing columns, and when you need to cleanse and prepare data.
Watch this video about custom tables and columns:
The new columns also provide Designers with additional fields to use as-is, or as a basis for even more advanced calculations in their widgets. You can use SQL to customize the values contained within the custom columns.
There are some limitations to this feature. For more information, see below.
To add a new column:
In the Navigation Pane, select and click Add Custom Column.
In the ElastiCube model, select the table and click and Add Custom Column.
The new column will be added to the table, and an SQL Editor is displayed where you define your custom SQL expression.Note:
For live connections, only “Fields” appears in the left-hand panel.
In the New Custom Column field, enter the name of your custom column and click .
In the SQL Editor, enter your custom expression.
Click to add your column to the table.
Custom Field Use Cases
Here are some typical scenarios for creating custom fields.
In live models, the SQL syntax is derived from the data source syntax. This also means that the column expression works on top of the actual source table. So, for instance, if a column was renamed in the live model, the new name cannot be used in the column expression. Instead, use the original column name from the data source.
Example: Snowflake JSON field Extraction
There are many ways to extract JSON fields from Snowflake. The following is one method.
If JSON_DATA is the column, extract JSON fields from it using the following Snowflake syntax:
For instance, to extract the “title” property from the JSON field as a string, use the following custom column expression:
In the following example, the expression goes down two nested levels to extract the full name from the data source as a string:
For more information, see the Snowflake documentation .
Row Level Calculations
Calculate revenue from your sales data.
Gross Revenue = (Unit Price * QuantitySold)
Net Revenue = (Unit Price * QuantitySold) - (Unit Cost * QuantityPurchased)
Time Difference Calculations
Work out the arrival time based on due and actual arrival dates.
Relative Difference Calculations
Figure out the relative difference between your price and competitor price.
Create data buckets according to your required business break points.
WHEN [PriceVsCompetitor%] < -0.05 THEN '-5%'
WHEN [PriceVsCompetitor%] >= -0.05 AND [PriceVsAvgCompetitor%] <= 0.05 THEN '-5%/+5%'
WHEN [PriceVsCompetitor%] > 0.05 THEN '+5%'
Create attributes to translate data talk to more coherent categories.
WHEN Region = 1 THEN 'USA'
WHEN Region = 2 THEN 'EUR'
WHEN Region = 3 THEN 'ASIA'
Convert dates into a numeric representation.
getyear(Date)*10000+getmonth(Date)*100+getday(Date) AS DateNum
Convert text into dates.
Date Period Comparisons Over Time
Create month to date and year to date calculations.
Click here for a support article with more information.
Importing from Another Table
See Adding Custom Tables to learn more.
- SELECT statements are not supported
- Live Custom Columns can only be applied to base tables. This feature cannot be applied to live table queries.
- Live Custom Columns cannot be based on other live Custom Columns.
- After you change the data type of a Live custom column, any dashboard filters that use this column need to be recreated.