# Calculated Fields

### Calculated Fields

1. To create a calculated field, choose a published dataset by clicking the green + sign:
1. Add the Field Name, Formula and click Validate:
1. Once the formula Validates successfully, click Save Field. For example, to add a calculated field of 'Profit':

This calculated field can now be used as a field from your dataset!

#### Calculated Fields Examples

##### Dynamic Ratios
• A ratio that dynamically calculates as the underlying data changes.
• If dividing 2 integers, multiply the numerator by 1.0 to return a decimal output
• Ex: Clickthrough Rate = SUM(clicks) * 1.0 /SUM(impressions)
##### Basic Math
• Simple arithmetic between columns in your dataset
• Ex: Profit = Revenue - Cost
##### Date Functions
• Easily calculate the difference between two dates, or between a date and the current date.
• Ex: DATEDIFF(day, project_start, project_end)
##### Create Categories and Groupings
• Groupings and categories can be created if they do not already exist in the dataset using Case When statements.
• Ex: CASE WHEN customers < 5 , THEN 'SMB', ELSE 'Majors'
##### Combining Aggregations
• Get a result across data aggregations
• Ex: Revenue = SUM(profit) - SUM(cost)
##### Percent of a Whole
• Get a percentage of a segment over a whole
• Ex (percent of revenue that comes from the iOS platform): SUM(CASE WHEN [Platform]='iOS' THEN [Price] else 0 end) / SUM([Price])