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

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
slacayo
Contributor III
Contributor III

Filter a loaded table based on other table columns

I have a  main table:

t1:
LOAD * INLINE [      id, ts, col1, col2 ,col3      1, t1, . . .      1, t2, . . .      1, t3, . . .
1, t4, . . .      2, t5, . . .      2, t6, . . .      3, t7, . . . ];

 Where id and ts (time-stamp) are really the only important columns for this example, however my table has about 25 total. 

I have another table, which I want to use to more or less filter the larger one. Table1 has all the contents of table2. The tables above and below are a small sample of much larger tables. 

LOAD * INLINE [
     id,  ts,      
1, t2,     
1, t4,    
2, t5,   
3, t7, ];

 

Essentially I want the final product to look like this:

id ts col1 col2 col3
1 t2                   .                  .                  .
1 t4                    .                  .                  .
2 t5                   .                  .                  .
3 t7                  .                  .                  .

 

Essentially what is happening is im joining the bigger table onto the smaller one and only keeping all the extra columns from the large table as long as their respective `id` and `ts` exist in the smaller table

Labels (3)
1 Reply
maxgro
MVP
MVP

I think you can filter in the script with a KEEP

https://help.qlik.com/en-US/sense/August2021/Subsystems/Hub/Content/Sense_Hub/Scripting/ScriptPrefix...

http://qlikviewapuntes.blogspot.com/2014/01/esquema-keep.html

 

try with this script

t1:
LOAD * INLINE [
id, ts, col1, col2 ,col3
1, t1, . . .
1, t2, . . .
1, t3, . . .
1, t4, . . .
2, t5, . . .
2, t6, . . .
3, t7, . . .
];


t2:
LOAD * INLINE [
id, ts,
1, t2,
1, t4,
2, t5,
3, t7,
];


trk:
RIGHT KEEP (t1)
LOAD id, ts
RESIDENT
t2;

DROP TABLE t2;
DROP TABLE trk;