---
schema_version: "1"
id: e803dfc2ebbe1073d476c3860afc1b6e8dd4021b52cd61d66db6ae80b1ecbd6c
title: Calculate the Slope of the Regression Line
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-examples-stats.md
canonical_url: https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-examples-stats.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: 4ff1a37bf64a084d2a74637c55bfc9d25eda3e914f75edcf5d7bbb2d97313246
products:
  - Analytics SAQL Developer Guide
  - analytics
---

# Calculate the Slope of the Regression Line

Use SAQL to perform linear analysis on your data to find the line that best fits the data. Then use .`regr_slope` to return the slope of this line.

## Example - Calculate the Relationship Between Number of Activities and Deal Amount

Suppose that you have a dataset that includes the number of activities (such as meetings) and the won opportunity amount.

![Sample scatter plot.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_fn_agg_regint.png)

How much bigger will the deal size be for each extra activity? `regr_slope` performs a linear analysis on your data then calculates the slope (that is, the increased amount you win for each extra activity).

```nolang
q = load "data/sales";
q = group q by all;

--trunc() truncates the result to two decimal places
q = foreach q generate trunc(regr_slope('Amount', 'NumActivities'),2) as 'Gain per Activity';
```

Based on your existing data, every extra activity that you have tends to increase the deal size by \$1.45 million, on average.

![Diagram showing slope of a regression line.](https://developer.salesforce.com/media/bi_dev_guide_saql/bi_saql_fn_agg_slope.png)

**See Also**

- [regr_slope()](https://developer.salesforce.com/docs/analytics/bi-dev-guide-saql/guide/bi-saql-fn-agg-rs.md)
