# Joining two tables

**URL:** <https://community.dynatrace.com/t/joining-two-tables/41762>\
**Category:** DQL\
**Tags:** dql, services-classic, notebooks\
**Created:** [September 25, 2023, 7:36pm UTC](https://community.dynatrace.com/t/joining-two-tables/41762 "2023-09-25T19:36:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![samgar-kali](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@samgar-kali](https://community.dynatrace.com/u/samgar-kali)\
**Post date:** [September 25, 2023, 7:36pm UTC](https://community.dynatrace.com/t/joining-two-tables/41762/1 "2023-09-25T19:36:11Z")

</div>

I am trying to join two tables.&nbsp;dt.entity.service&nbsp;and&nbsp;“Davis problem events”.&nbsp;I believe the syntax is correct, and I am not seeing any errors. However, the following DQL shows that there are no matching services. Which sounds incorrect. Am I missing something?

```auto
fetch events, from:now()-24h, to:now()
| filter event.kind == "DAVIS_PROBLEM"
| fields event.start, event.end, display_id, event.category, event.name, affected_entity_ids, root_cause_entity_id, event.status, resolved_problem_duration
| sort event.start desc
| lookup [fetch dt.entity.service],sourceField:affected_entity_ids,lookupField:id
| summarize count=count(), by:{lookup.entity.name}

```

 ![samgarkali_0-1695670515342.png](https://global.discourse-cdn.com/dynatrace/original/3X/5/5/55bc9049edfb9911172cce9dcc2984b4fbf456c7.png)

---

<div class="post-metadata">

**Author:** ![Tiit\_Hallas](https://avatars.discourse-cdn.com/v4/letter/t/cdc98d/32.png) [@Tiit\_Hallas](https://community.dynatrace.com/u/Tiit_Hallas)\
**Post date:** [September 25, 2023, 8:01pm UTC](https://community.dynatrace.com/t/joining-two-tables/41762/2 "2023-09-25T20:01:30Z")

</div>

The issue is coming from different data types: the source field “affected\_entity\_ids” is an array, while the lookup field “id” is a string. The quickest fix here would be to use “expand” to break down the array, e.g:

```markup
fetch events, from:now()-24h, to:now()
| filter event.kind == "DAVIS_PROBLEM"
| fields event.start, event.end, display_id, event.category, event.name, affected_entity_ids, root_cause_entity_id, event.status, resolved_problem_duration
| expand affected_entity_ids
| lookup [fetch dt.entity.service], sourceField:affected_entity_ids, lookupField: id

```
