Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
jeevays7
Partner - Creator III
Partner - Creator III

pass the field name into expression using variable

Hi All,

I have two tables like below

Table 1:

  

DateNAMEBase_CurrValue
1AUSD10
2BEUR10
3CUSD20

Table 2:

DateEURUSD
12010
21050
33020

the above table are linked with Date.

now i need the below Result:

  

DateNAMEBase_CurrValue
1AUSD100
2BEUR100
3CUSD400

Here im using below expression:

SUM(Value*(vCurrecy))


inside the variable i have the expression

if(Base_Curr='EUR','EUR','USD')



Explanation of above result table:

  

DateNAMEBase_CurrValueexplainationex
1AUSD100here base currecy is USD so USD values will come ie.10) from table 210*10
2BEUR100here base currecy is EUR so EUR value will come ie.10) from table 210*10
3CUSD400here base currecy is USD so USD values will come ie.20) from table 220*20
12 Replies
MK_QSL
MVP
MVP

I don't know why you insist not to do it without Key.

You can do it without using Key but then you have to use Date & Base_Curr.

Le me give you real world scenario.

You might have table like below.

Date, EUR, USD

01/07/2017, 20, 10

10/07/2017, 10, 50

14/07/2017, 30, 20

In short, you don't have currency rates for all days. In fact, to reduce the number of lines, we have stored currency rates when there is actually a change wrt previous day.

How to tackle this type of issue with your question...? You can use below code for that.

CrossTable(Base_Curr,Cur) 

TempT2: 

Load * Inline 

Date, EUR, USD 

01/07/2017, 20, 10 

10/07/2017, 10, 50 

14/07/2017, 30, 20 

];

Temp_Currency:

Load

Date as FromDate,

Date(IF(Base_Curr = Previous(Base_Curr), Previous(Date)-1,Date(Date+1))) as ToDate,

Base_Curr,

Cur

Resident TempT2

Order By Base_Curr, Date Desc;

Drop Table TempT2;

T1: 

Load * Inline 

Date, NAME, Base_Curr, Value 

02/07/2017, A, USD, 10 

12/07/2017, B, EUR, 10 

14/07/2017, C, USD, 20 

]; 

Inner Join

IntervalMatch(Date, Base_Curr)

Load FromDate, ToDate, Base_Curr Resident Temp_Currency;

Left Join(T1)

Load * Resident Temp_Currency;

Drop Table Temp_Currency;

Drop Field FromDate, ToDate;



jeevays7
Partner - Creator III
Partner - Creator III
Author

Thank you andrew

jeevays7
Partner - Creator III
Partner - Creator III
Author

Thank you for your replyWallo