# Correlate Multiple Query Results with Dynatrace DQL

**URL:** <https://community.dynatrace.com/t/correlate-multiple-query-results-with-dynatrace-dql/44364>\
**Category:** DQL\
**Tags:** dql, dynatrace-managed, notebooks, logs\
**Created:** [February 29, 2024, 3:58pm UTC](https://community.dynatrace.com/t/correlate-multiple-query-results-with-dynatrace-dql/44364 "2024-02-29T15:58:45Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [February 29, 2024, 3:58pm UTC](https://community.dynatrace.com/t/correlate-multiple-query-results-with-dynatrace-dql/44364/1 "2024-02-29T15:58:45Z")

</div>

Hello!

I need to relate two events.

I have logs of two events:  
1. Errors in my store cart (contains customer ID)  
2. Checkout in my cart (contains customer ID)

I need two views:  
1. Customers who completed their purchase but had errors in their cart  
2. Customers who had an error but did not complete the purchase.

I thought of two methods:

Create a log extraction metric for each action (cart error and checkout), using the customer ID as a dimension. But I don’t know how I can relate it in the data explorer to get the visualization I need.

The second method would be to create a single metric that stores both logs (cart error and checkout), using the customer ID as a dimension. But I also don’t know how I can relate in data explorer.

---

<div class="post-metadata">

**Author:** ![Eric\_Yu](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/eric_yu/32/20360_2.png) [@Eric\_Yu](https://community.dynatrace.com/u/Eric_Yu)\
**Post date:** [February 29, 2024, 4:16pm UTC](https://community.dynatrace.com/t/correlate-multiple-query-results-with-dynatrace-dql/44364/2 "2024-02-29T16:16:10Z")

</div>

If you’re on SaaS, try doing it using DQL instead straight into the new dashboards. This might be helpful:

> **[DQL correlation and join commands](https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/commands/correlation-and-join-commands)**
>
> DQL correlation and join commands

> **[DQL correlation and join commands](https://docs.dynatrace.com/docs/platform/grail/dynatrace-query-language/commands/correlation-and-join-commands)**
>
> DQL correlation and join commands

Using a join or lookup, you should be able to merge those two into one record, something like this:

```markup
fetch logs
| filter isNotNull(dt.entity.host)
| lookup sourceField:dt.entity.host, lookupField:id, prefix:"host.", [fetch dt.entity.host | fields id, os = osType]
| limit 10

```

Here’s additional documentation on GRAIL on the latest Dashboards:&nbsp;[Add data to a dashboard — Dynatrace Docs](https://docs.dynatrace.com/docs/shortlink/dashboard-component-data)

---

<div class="post-metadata">

**Author:** ![wellpplava](https://avatars.discourse-cdn.com/v4/letter/w/d26b3c/32.png) [@wellpplava](https://community.dynatrace.com/u/wellpplava)\
**Post date:** [February 29, 2024, 4:18pm UTC](https://community.dynatrace.com/t/correlate-multiple-query-results-with-dynatrace-dql/44364/3 "2024-02-29T16:18:28Z")

</div>

This works well, but one of the problems is that we need to store this data in metrics.
