---
schema_version: "1"
id: a14d00dbd2180e10d31f6217d011b5ab88920f0d4272506743994fc637c7625f
title: Create a Derived Measure
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/analytics/bi_dev_guide_saql/guides/concept/bi-saql-derived-measure.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-derived-measure.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 362207c4a304ead841b92de8311f0f40dfd7391c6bd6fff4429e4151e4a4c1c7
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# Create a Derived Measure

Perform calculations on existing measures and use the result to create a new, or derived, measure.

CRM Analytics calculates the value of derived measures at run time using the values from other fields.

**note:** You can also create a derived measure in a dataflow rather than at runtime using SAQL. Measures created during a dataflow are calculated when the data is imported and may result in better performance.

## Example - Calculate the Time to Win

Suppose that you have an Opportunities dataset with the Close Date and Open Date fields. You want to see the number of days it took to win the opportunity. Use CloseDate_day_epoch and CreatedDate_day_epoch to create a derived measure called Time to Win: `('CloseDate_day_epoch'- 'CreatedDate_day_epoch') as 'Time to Win'`.

The field Time to Win is calculated at run time:

```nolang
q = load "Opportunities";
q = foreach q generate 'CloseDate_day_epoch' as 'CloseDate_day_epoch', 'CreatedDate_day_epoch' as 'CreatedDate_day_epoch', 'Opportunity_Name' as 'Opportunity_Name', ('CloseDate_day_epoch'- 'CreatedDate_day_epoch') as 'Time to Win';
```

The resulting table contains the number of days to win each opportunity:

![Derived dimension shows time to win](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_derived_measure.png)
