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: 
xingstar97
Contributor III
Contributor III

select values from table A only if that value exist in table B

I have table A and table B. Table A has date, dateid; table B has dateid. Dateid is the key between them. I want to show date in table A only when dateid exist in Table B. In another word, I want to show the date corresponding to dateid in table B. What should I do? Note there are more values of dateid in table A than table B.

Labels (4)
1 Solution

Accepted Solutions
PhanThanhSon
Creator II
Creator II

Hi,

Here are the two options that come to mind ad hoc: Left Keep and Where Exists:

TABLE_B:
LOAD * INLINE [
DATEID
3
4
5
];

LEFT KEEP(TABLE_B)
TABLE_A:
LOAD * INLINE [
DATEID
3
4
1];

OR 

TABLE_B:
LOAD
DATEID AS %KEY,
DATEID AS DATEIDTEMP
INLINE [
DATEID
3
4
5
];

TABLE_A:
LOAD DATEID AS %KEY,
DATEID 
INLINE [
DATEID
3
4
1]
Where Exists(DATEIDTEMP, DATEID);

 

PhanThanhSon_0-1709150259875.png

Both results return precisely the rows that exist in Table_B.

 

Best regards Son

View solution in original post

2 Replies
PhanThanhSon
Creator II
Creator II

Hi,

Here are the two options that come to mind ad hoc: Left Keep and Where Exists:

TABLE_B:
LOAD * INLINE [
DATEID
3
4
5
];

LEFT KEEP(TABLE_B)
TABLE_A:
LOAD * INLINE [
DATEID
3
4
1];

OR 

TABLE_B:
LOAD
DATEID AS %KEY,
DATEID AS DATEIDTEMP
INLINE [
DATEID
3
4
5
];

TABLE_A:
LOAD DATEID AS %KEY,
DATEID 
INLINE [
DATEID
3
4
1]
Where Exists(DATEIDTEMP, DATEID);

 

PhanThanhSon_0-1709150259875.png

Both results return precisely the rows that exist in Table_B.

 

Best regards Son

rwunderlich
Partner Ambassador/MVP
Partner Ambassador/MVP

If you want to do this in a chart, one method is:

=Aggr(Only({$*<somefield={*}>}date), date)

where "somefield" is a field that exists only in Table B.

-Rob
http://www.easyqlik.com
http://masterssummit.com
http://qlikviewcookbook.com