# Joining tables in one dataset

**URL:** <https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669>\
**Category:** Q&A\
**Tags:** admin, quick-sight\
**Created:** [November 23, 2023, 9:29am UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669 "2023-11-23T09:29:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 9:29am UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/1 "2023-11-23T09:29:26Z")

</div>

Hello,  
I have 2 fact tables, with the same granularity level, and 1 dim table that needs to be connected to the 2 fact tables.  
The problem is, that each fact table has different data in the join fields, so the dim tables will join only to the table I’ll make the connection with.

For example:  
Fact table 1-  
Date FarmId val1  
1.1.23 1 1  
1.2.23 2 1  
Fact Table 2-  
Date FarmId val2  
1.3.23 1 1  
1.4.23 2 1  
Dim table-  
FarmId FarmName  
1 Edo  
2 Eli

How can I get a dataset that looks like this:  
Date FarmName val1 val2  
1.1.23 Edo 1 1  
1.2.23 Eli 1 1  
1.3.23 Edo 1 1  
1.4.23 Eli 1 1

Thanks in advance,  
Mia

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [November 23, 2023, 9:46am UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/2 "2023-11-23T09:46:26Z")

</div>

Hi @miap  
did you tried something like  
 ![grafik](https://d1wl4jav5dp96l.cloudfront.net/original/2X/c/cd401a370c7c1d564b217ddccaedf20579bb772b.png)  
BR

---

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 11:47am UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/3 "2023-11-23T11:47:52Z")

</div>

But in case there are similar dates in both fact tables, the two fact tables won’t connect based on the date, only based on the ‘farmId’ won’t it?  
The join between the fact tables needs to be on the fields ‘date’ and ‘farmId’.

---

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 12:14pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/4 "2023-11-23T12:14:59Z")

</div>

I’m sorry, the example wasn’t good enough,  
Here is a better example:

![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/6/6729cfa24535e9bd0c24f81ff48ba051ca8c2e48.png)

\*I’ll also mention that the 2 fact tables are from different data sources.

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [November 23, 2023, 12:31pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/5 "2023-11-23T12:31:19Z")

</div>

Try to join the fact tables with `full join` on `Date` and `Farm id` with in one datasetA.  
Use that datasetA in another datasetB and `left join` on `farm id` the dim.

---

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 12:51pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/6 "2023-11-23T12:51:29Z")

</div>

I’m not familiar with joining between 2 datasets, how does it work?

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [November 23, 2023, 1:15pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/7 "2023-11-23T13:15:47Z")

</div>

please check

> **[Joining data - Amazon QuickSight](https://docs.aws.amazon.com/quicksight/latest/user/joining-data.html)**
>
> Join tables, files, and SQL queries using the Amazon QuickSight join interface.

---

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 1:29pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/8 "2023-11-23T13:29:00Z")

</div>

Great thank u very much, it’s a good solution.

Another question, now I have 2 different date fields, is there a way to unit them into one date field?

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [November 23, 2023, 2:06pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/9 "2023-11-23T14:06:23Z")

</div>

just exclude one in the dataset. 😉

---

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 2:36pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/10 "2023-11-23T14:36:43Z")

</div>

Sure, but they are not sharing the same data:

The output of joining these 2 datasets is:  
 ![image](https://d1wl4jav5dp96l.cloudfront.net/original/2X/2/2944d1f3dfba7ffad26a03711d5d968f18845ebb.png)

And I want to have one date that contains both dates.

---

<div class="post-metadata">

**Author:** ![ErikG](https://d2orw1595917va.cloudfront.net/user_avatar/community.amazonquick.com/erikg/32/14524_2.png) [@ErikG](https://community.amazonquick.com/u/ErikG)\
**Post date:** [November 23, 2023, 3:04pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/11 "2023-11-23T15:04:25Z")

</div>

ah ok.  
then create a new field. Something like  
date = `ifelse( isNull({date fact 1}) , {date fact 2}, {date fact 1})`

---

<div class="post-metadata">

**Author:** ![miap](https://avatars.discourse-cdn.com/v4/letter/m/ed8c4c/32.png) [@miap](https://community.amazonquick.com/u/miap)\
**Post date:** [November 23, 2023, 3:06pm UTC](https://community.amazonquick.com/t/joining-tables-in-one-dataset/21669/12 "2023-11-23T15:06:10Z")

</div>

Ok, that will work 🙂

Thank you, u are very helpful
