Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Join two tables

I have two tables like the following the common field for both the table is Currency_Code from Rate table and Currency from Fact table.

when I join together using a syntactic key i can see may duplicate data.

Requirement is as  I need a table that should match the same currency in the both tables and the also need to get the Ex_Rate on if the invoice date is  = Date in Rate table.

please give a idea....

Rate:

Date,

Currency_Code,

Ex_Rate

From Table1;

Fact:

Id,

Location,

Invoice_Number,

Invoice_Date,

Weight,

Currency,

Amount

from Table2;

Thanks and Regards

Chriss

1 Solution

Accepted Solutions
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Since the Currency rate is driven by two fields - Currency Code and Date, you have 2 choices:

1. Keep two separated tables, linked by 2 fields, which causes the synthetic key. You may chose to replace the synthetic key with a combo key that's generated manually.

2. Join the Currency Rate into the Fact, based on the two join fields (the Currency code and the date). I'd recommend this approach, because it is likely to perform better:

Fact:

LOAD

...

;

left join (Fact) load

Date as Invoice_Date,

Currency_Code as Currency,

Ex_Rate

From Table1;

best,

Oleg Troyansky

www.masterssummit.com

View solution in original post

5 Replies
Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Since the Currency rate is driven by two fields - Currency Code and Date, you have 2 choices:

1. Keep two separated tables, linked by 2 fields, which causes the synthetic key. You may chose to replace the synthetic key with a combo key that's generated manually.

2. Join the Currency Rate into the Fact, based on the two join fields (the Currency code and the date). I'd recommend this approach, because it is likely to perform better:

Fact:

LOAD

...

;

left join (Fact) load

Date as Invoice_Date,

Currency_Code as Currency,

Ex_Rate

From Table1;

best,

Oleg Troyansky

www.masterssummit.com

Not applicable
Author

Hi Oleg,

Awesome, its works like a gem... as I would like to more on this how do i learn this where I can get this stuff, please share your idea.

Thanks and Regards

Chriss

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Chriss,

this is part of advanced Data Modeling. You can learn some basic ideas in the standard QlikView education curriculum (Developer Class), a bit more in the "Advanced Topics in Design and Development".

You can read about data modeling in Barry Harmsen's book "QlikView 11 for Developers".

Beyond that, the only advanced technical venue that I'm aware of is the Masters Summit for QlikView, where Barry Harmsen is teaching an excellent 4-hours Data Modeling class.

best,

Oleg Troyansky

www.masterssummit.com

Not applicable
Author

Hi Oleg,

Thanks for your valuable information, let me try that book "QlikView 11 for Developers". The solution what your given is working fine but still I am missing one thing.

The requirement is need to convert the Amount with a Ex_Rate when the Currency is selected, the twist is when I select the 'EUR' currency it shows the invoices who's Currency owe's the EUR the same for all the currency but what I want when I select the 'EUR' currency all the invoices based on their currency the Amount / Ex_Rate.

As I need this in a script, please give some clue to proceed further.

Thanks and Regards

Chriss

Oleg_Troyansky
Partner Ambassador/MVP
Partner Ambassador/MVP

Well, this is a different requirement and a different solution...

First, you want to convert all the original transactions to a common currency, for example USD or EUR.

Then, you need to calculated all the transactions in the desired currencies for the presentation. You can either pre-calculate multiple amounts in the script or keep the rates in a table and calculate it on the fly.