A common use case in reporting and data visualization is to display key performance indicators (KPI) as ratios of one indicator as compared to another. For example, suppose you are measuring the completion rate of an online coding academy. A KPI for the course is completion rate, which we'll define here as:

`Course completions / Course registrations`

If your dataset already contains this data then you can display the result in Data Studio. But what if you need to calculate it in your report, or need to display completion rates based on filtered data? The solution is to use data blending.

Say your data looks like this:

| **Event Category** | **Event Action** | **Course Number** | **Unique Events** |
|---|---|---|---|
| Course Certificate | Download | 9 | 299 |
| Course Complete | Fail | 8 | 21 |
| Course Complete | Fail | 9 | 86 |
| Course Complete | Pass | 9 | 337 |
| Course Complete | Fail | 6 | 34 |
| Course Complete | Pass | 7 | 363 |
| Course Complete | Fail | 7 | 17 |
| Registration | Register | 8 | 814 |
| Registration | Register | 7 | 475 |
| Registration | Register | 5 | 574 |
| Registration | Register | 9 | 1078 |
| Registration | Unregister | 6 | 22 |

## Step 1: Calculate the course completions

1. Add a scorecard to your report. Call it **Course Completions**.
2. Set the metric to *Unique Events*.
3. Add a filter to the scorecard to ignore non-completion events:

   `Include`**`Event Category`** `= "Course Complete"`

   `AND`

   `Include`**`Event Action`** `= "Pass"`

Based on the sample data, the scorecard would look like this:

|---|
| Course Completions 700 |

## Step 2: Calculate the course registrations

1. Add a scorecard to your report. Call it **Course Registrations**.
2. Set the metric to *Unique Events*.
3. Add a filter to the scorecard to ignore non-registration events:

   `Include`**`Event Category`** `= "Registration"`

   `AND`

   `Include`**`Event Action`** `= "Register"`

Based on the sample data, the scorecard would look like this:

|---|
| Course Registrations 2,941 |

## Step 3: Blend the data from the scorecards

1. Select the *Course Registrations* scorecard, then select the *Course Completions* scorecard.
2. Right-click, then select **Blend data**.

This creates a new scorecard that automatically calculates the ratio between those metrics:

|---|
| Course Completion Rate 23.80% |

> [!IMPORTANT]
> **Tip:**
>
> To create more complex calculated fields or change the number display:
>
> 1. Select the blended scorecard.
> 2. Edit the metric.
> 3. Enter a new formula and/or change the field **Type** to match the data.
>
> ![A user selects a scorecard chart that displays 72.76% Users/Sessions and then edits the Users/Sessions metric definition by selecting the Type icon next to the field name.](https://docs.cloud.google.com/static/data-studio/images/edit-scorecard-2019-09-12-rge.png)

## Related resources

Learn more about how blending works:

- [About data blending](https://docs.cloud.google.com/data-studio/how-blends-work)
- [Use blending to re-aggregate data](https://docs.cloud.google.com/data-studio/use-blending-to-reaggregate-data)