# Workflows – using the Join by Key block

The “Join by Key” block serves as the bridge between two datasets. Conduit processes each row in the primary dataset, seeking matches in the secondary dataset based on a specified key. Rows from the secondary dataset that don't find a match in the primary dataset are excluded from the final output.

This feature could be useful, when you trying to merge related data from different sources, such as Ad networks

**Here's a practical example:**

1. Start a Workflow by pulling data from Facebook Ads and Google Analytics accounts
2. Add the Join by Key block into your Workflow.
3. Set up the block by choosing the primary and secondary datasets. In our case, let's enrich our advertising data with insights from the analytics system.
4. Select "Demo Facebook" as the Primary dataset.
5. Choose "Demo Google Analytics" as the Secondary dataset.

Now, configure the key matching process. In our example, we aim to find values from Demo Google Analytics and incorporate them into rows of the primary dataset where Date and Ad Campaign values align.

![](/files/OGfkLOLa4lLjDG5Trpcm)

**Applying pro-data distribution for metrics**

The Join by Key block in Conduit comes with an additional configuration - the "Apply pro-rata distribution for metrics" setting. This feature addresses scenarios where one row from a dataset corresponds to multiple rows in another dataset, potentially leading to an increase in metric values due to duplicated rows.

Here is an example:

Facebook Data

| Data       | Campaign | Clicks |
| ---------- | -------- | ------ |
| 2024-01-01 | Ads      | 11     |
| 2024-01-01 | Ads      | 11     |
| 2024-01-02 | Ads      | 15     |

Google Analytics

| Date       | Ad Campaign | Medium | Purchases |
| ---------- | ----------- | ------ | --------- |
| 2024-01-01 | Ads         | m1     | 3         |
| 2024-01-01 | Ads         | m2     | 4         |
| 2024-01-02 | Ads         | m3     | 1         |
| 2024-01-02 | Ads 2       | m1     | 5         |

As a result of joining, we should receive a dataset with three rows\ <br>

| Date       | Ad Campaign | Medium | Clicks | Purchases |
| ---------- | ----------- | ------ | ------ | --------- |
| 2024-01-01 | Ads         | m1     | 6      | 3         |
| 2024-01-01 | Ads         | m2     | 5      | 4         |
| 2024-01-02 | Ads         | m3     | 15     | 1         |

As you can see, we encountered a duplication issue on January 1st, causing the total Clicks to increase from 26 to 37. By activating this setting, we would achieve a different outcome.

| Date       | Ad Campaign | Medium | Clicks | Purchases |
| ---------- | ----------- | ------ | ------ | --------- |
| 2024-01-01 | Ads         | m1     | 6      | 3         |
| 2024-01-01 | Ads         | m2     | 5      | 4         |
| 2024-01-02 | Ads         | m3     | 15     | 1         |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.getconduit.app/workflows/workflows-using-the-join-by-key-block.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
