Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello.
I have two tables and one problem to solve. I need to attribute Key1 to Name somehow. I quite newbie in qlik products so even if solution is obvious, for me it is something new to lear.
Table1.
Name |
---|
Alpha |
Beta |
Gamma |
Delta |
Epsilon |
Zeta |
Table2.
Key1 | Value |
---|---|
001 | 1001 |
002 | 354 |
003 | 544 |
AC2 | 354 |
A0T | 5453 |
AC2 | 545 |
002 | 68 |
004 | 787 |
002 | 336 |
I need to attribute Name to Keys for example in this way:
Alpha = 001
Beta = AC2
Gamma = 003
Atc...
The data in your post does not have enough information for you to do this.
How does the script know that Beta = AC2?
And Gamma = Epsilon (Epsilon is not even a key - is that a typo)?
Gamma = 003 (already corrected, thank you)
This is my question. How to write it in Qlik script to attribute these tables correctly?
Hi,
The only ways I can suggest with what is posted is to have a if statement on load or making an apply map.
IF ( Name = 'Alpha', '001'
IF(Name ='Beta', 'AC2'
IF(......
)
)
) as Key1
Mark
Mark, Thank you for advise, it actually works with if statement, but these tables are quite long, so i need faster way. I've seen a few examples of using map function but i connot figure out how to use it in my case.
HI,
We create an inline table with your Name and Key1
As Something like
Table1:
LOAD * INLINE [
Name, Key1
Alpha, 001
...., ...
];
MapTable:
Mapping Load
Name,
Key1
Resident Table1;
Drop Table Table1;
Load
Name,
ApplyMap('MapTable',Name) as Key1
From 'Your location'
Hope this helps
Mark
Hi Kamil,
As Jonathan said, u need to give some more details. For example, from table 1 and table 2 you have provided, how you are saying that Beta = AC2.
I guess we are missing that link.
How 'Name' from Table1 is linked with 'Key1' of Table2 ?
This version of Mark's approach would be slightly more efficient because you can doing a mapping load with an inline load
MapTable:
Mapping LOAD * INLINE [
Name, Key1
Alpha, 001
...., ...
];
Load
Name,
ApplyMap('MapTable',Name) as Key1
From 'Your location'
-Josh
Qlik