Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Thomas_Qlik
Contributor II
Contributor II

Measure that checks if a value in one table also exists in a second table

I want to build a table visualization that contains all the values from table/column  A.TO_BE and (in a second column) the output of a measure that checks, whether the value also exists in a second table/column B.AS_IS. If the value  exists in the second table, the MEASURE should return "OK", otherwise "NOK".  How would I do this in Qlik Sense?

Many thanks,

Thomas

 

Expected Output:

A.TO_BE | MEASURE

Apple       |    OK

Pear          |    OK

Cherry      |   NOK

 

Content of table A:

A.TO_BE

Apple

Pear

Cherry

 

Content of table B:

B.AS_IS

Apple

Pear

 

 

Labels (1)
1 Solution

Accepted Solutions
Gabbar
Specialist
Specialist

Use this :
if(aggr(Count({<Flag_A={1},Flag_B={1}>}A.TO_BE),[A.TO_BE])>0,'OK','NOK')

View solution in original post

4 Replies
Gabbar
Specialist
Specialist

Add a table flag in both tables in script, or (There can be other columns in both table which you can use).
TableA:
Load A.TO_BE,'1' as Flag_A  from Source;
TableB:
Load B.AS_IS as A.TO_BE,'1' as Flag_B from Source;


then in your table in UI add A.TO_BE as Dimension, 
Add measure as 
If(Count({<Flag_A={'1'},Flag_B={'1'}>}A.TO_BE)>0,'OK','NOK')

IF you have columns in both table which can be used instead of flags you can do that do.

Thomas_Qlik
Contributor II
Contributor II
Author

I have adjusted my code as instructed.  When I add the  A.TO_BE as Dimension, my table shows all 3  entries. But once I add the Measure, the entry that does not exist in the second table will disappear, instead of remaing in the table and showing 'NOK' as value in the Measure column.

Gabbar
Specialist
Specialist

Use this :
if(aggr(Count({<Flag_A={1},Flag_B={1}>}A.TO_BE),[A.TO_BE])>0,'OK','NOK')

Thomas_Qlik
Contributor II
Contributor II
Author

The formula produces the expected result.

Many thanks, Gabbar!