Example Calculated Columns
Examples of calculated column expressions
Description
Data in dashboards can be augmented with calculated columns. Each dataset will contain a section for calculated columns. Calculated columns can be written and modified with PostgreSQL-flavored SQL.
Navigating to a dataset
In order to view and edit metrics and calculated expressions, perform the following steps:
- Sign into plaidcloud.com and navigate to dashboards
- From within visualize.plaidcloud.com, navigate to Data > Datasets
- Search for a dataset to view or modify
- Modify the dataset by hovering over the
edit
button beneathActions
Examples
count
COUNT(*)
min
min("MyColumnName")
max
max("MyColumnName")
coalesce (useful for converting nulls to 0.0, for instance)
coalesce("BaselineCost",0.0)
divide
divide, with a hack for avoiding DIV/0 errors
sum("so_infull")/(count(*)+0.00001)
Note: A better way to do this would be to check for a null or zero denominator and then coalese to zero rather than attempting the division.
conditional statement
CASE WHEN "Field_A"= 'Foo' THEN max(coalesce("Value_A",0.0)) - max(coalesce("Value_B",0.0)) END
Last modified December 18, 2023 at 7:42 PM EST: Added D3 Formatting content (cf1d691)