> For the complete documentation index, see [llms.txt](https://docs.fabricplan.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.fabricplan.com/planning-sheets/how-tos/infobridge/query-transformations/merge-queries.md).

# Merge queries

Use **Merge Query** to combine measures from multiple queries into a single query.

**Merge Query** simplifies reporting by combining related measures while preserving the existing row and column dimensions.

> \[!IMPORTANT] **Merge Query** works only when all selected queries use the same row and column dimensions. The queries can contain different measures.

**Merge Query** creates a new query. It doesn't modify the original queries.

### Example scenario

The following example uses two product-based queries.

Both queries use the same ProductName and Category dimensions but contain different measures.

The **Product Sales query** contains sales measures.

| ProductName | Category               | Units | Sales Amount |
| ----------- | ---------------------- | ----: | -----------: |
| Camera M300 | Cameras and camcorders |   415 |       78.28K |
| Camera M200 | Cameras and camcorders |   362 |       68.06K |
| Camera X300 | Cameras and camcorders |   381 |       71.25K |

The **Product Pricing query** contains pricing measures.

| ProductName | Category               | Unit Price | Unit Cost |
| ----------- | ---------------------- | ---------: | --------: |
| Camera M300 | Cameras and camcorders |     27.52K |    12.66K |
| Camera M200 | Cameras and camcorders |     22.56K |    10.37K |
| Camera X300 | Cameras and camcorders |     23.18K |    10.66K |

After you merge the queries, the new query contains the shared dimensions with measures from both queries.

| ProductName | Category               | Units | Sales Amount | Unit Price | Unit Cost |
| ----------- | ---------------------- | ----: | -----------: | ---------: | --------: |
| Camera M300 | Cameras and camcorders |   415 |       78.28K |     27.52K |    12.66K |
| Camera M200 | Cameras and camcorders |   362 |       68.06K |     22.56K |    10.37K |
| Camera X300 | Cameras and camcorders |   381 |       71.25K |     23.18K |    10.66K |

### Merge queries

This example merges the **Product Sales query** and **Product Pricing query**.

The **Product Sales query** contains the shared dimensions **ProductName** and **Category**, together with the **Units** and **Sales Amount** measures.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FJRIKDhkVQsrqOMMlEWcy%2Fproduct-sales-query.png?alt=media&amp;token=f5ccf754-9ee7-4000-90b8-15b7a4c8dbbe" alt=""><figcaption></figcaption></figure>

The **Product Pricing query** uses the same dimensions and contains the **Unit Price** and **Unit Cost** measures.

<figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FBCXxmTRczKBRHEzv1ZJc%2Fproduct-pricing-query.png?alt=media&amp;token=3e42c574-23c2-49ef-b84f-395d8c3544bd" alt=""><figcaption></figcaption></figure>

To merge queries:

1. On the **Home** ribbon, select **Merge Query**.
2. In the **Merge Query** dialog, add the queries that you want to merge.
3. For the **Product Sales query**, select the measures to include in the merged query.

   In this example, select:

   * **Sum of Units**
   * **Sum of Sales Amount**<br>

   <figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FFg6X47kVDBdxwzcO62Y3%2Fmerge-query-select-first-query.png?alt=media&amp;token=a2008b82-e751-4f37-adbc-5ca6daf55c07" alt=""><figcaption></figcaption></figure>
4. For the **Product Pricing query**, select the measures to include in the merged query.

   In this example, select:

   * **Sum of Unit Price**
   * **Sum of Unit Cost**

   <figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FR2c2ZU3ZPhPlnjzBN2nt%2Fmerge-query-select-second-query.png?alt=media&amp;token=74831a18-07d3-4782-83b9-b8dacd68a293" alt=""><figcaption></figcaption></figure>
5. Select **Apply**.<br>

   <figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2FAjuNHaLwJGvMzNSE73TJ%2Fmerge-query-ready-to-apply.png?alt=media&amp;token=6b94aac3-54d1-46d9-9391-46c72df945b4" alt=""><figcaption></figcaption></figure>

   <br>
6. Infobridge creates a new merged query.<br>

   The merged query preserves the shared row and column dimensions and combines the measures from all selected queries.<br>

   <figure><img src="https://257222532-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FUtolck8kt8atqxFPsEBn%2Fuploads%2F8KkeWJWkivJAlZxwBFK7%2Fmerged-query-results.png?alt=media&amp;token=d71bb38d-0c56-4f78-ac97-dbc56842d44f" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.fabricplan.com/planning-sheets/how-tos/infobridge/query-transformations/merge-queries.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
