Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hell All,
I am new to Qlik.
I have two tables similar to the following
I want a new field on Table1, NewField = DP (Table1)* DEM(Table2)
How can I achieve that
Hey,
Here is the general concept for how to achieve this:
1) Join tables
2) Resident load and multiply the two fields
Working script:
TestData:
Load * INLINE [
SEG, Year, DP
XY,2020,0.1
XY,2021,1.1
XY,2022,2.1
AA,2020,3.1
AA,2021,4.1
AA,2022,5.1
TT,2020,6.1
TT,2021,7.1
TT,2022,8.1
];
LEFT JOIN(TestData)
Load * INLINE [
SEG, Year, DEM
XY,2020,0.1
XY,2021,1.1
XY,2022,2.1
AA,2020,3.1
AA,2021,4.1
AA,2022,5.1
TT,2020,6.1
TT,2021,7.1
TT,2022,8.1
];
Table1:
NoConcatenate
LOAD
SEG
, Year
, DP
, DEM
, DP*DEM as NewField
RESIDENT TestData
;
Did Stoyan's post get you what you needed? If so, do not forget to return to the thread and use the Accept as Solution button on his post to mark things and give him credit for the assistance as well as let other Community Members know things worked. If you are still needing help, please leave a new update.
Regards,
Brett
Hey,
Here is the general concept for how to achieve this:
1) Join tables
2) Resident load and multiply the two fields
Working script:
TestData:
Load * INLINE [
SEG, Year, DP
XY,2020,0.1
XY,2021,1.1
XY,2022,2.1
AA,2020,3.1
AA,2021,4.1
AA,2022,5.1
TT,2020,6.1
TT,2021,7.1
TT,2022,8.1
];
LEFT JOIN(TestData)
Load * INLINE [
SEG, Year, DEM
XY,2020,0.1
XY,2021,1.1
XY,2022,2.1
AA,2020,3.1
AA,2021,4.1
AA,2022,5.1
TT,2020,6.1
TT,2021,7.1
TT,2022,8.1
];
Table1:
NoConcatenate
LOAD
SEG
, Year
, DP
, DEM
, DP*DEM as NewField
RESIDENT TestData
;
Did Stoyan's post get you what you needed? If so, do not forget to return to the thread and use the Accept as Solution button on his post to mark things and give him credit for the assistance as well as let other Community Members know things worked. If you are still needing help, please leave a new update.
Regards,
Brett
//Mapping table
Table1:
Mapping
Load
SEG,
DP
From Table1;
//Mapped here
Table2:
Load
ApplyMap('Table1',SEG,Null()) as DP,
SEG,
Year,
DEM
From Table2;
//Resident Table calculate here
Table3:
Load
SEG,
Year,
DEM*DP as Multiplication
Resident Table2;
Drop Table Table2;