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: 
Anonymous
Not applicable

Match fields from two different tables

Hi all,

I have an issue when trying to return a value, 'Yes' or 'No', based on whether the value of a field (Field1) from one table appears in the field (Field2) of another table.

The tables appear like this:

Table1:

TrainingField1
ABCJohn
ABCMike
ABCMary
ABCTom

Table2:

TrainingField2
ABCJohn
ABCPat
ABCTom

Basically, I'd like my chart to display with Training and Field1 as dimensions with the result 'Yes' or 'No' as a calculated expression called Complete if the value of Field1 matches Field2:

TrainingField1Complete
ABCJohnYes
ABCMikeNo
ABCMaryNo
ABCTomYes

I can get it to work generally using an IF or IF(Match) statement, but only if both fields are selected as dimensions in the chart.

=If(Match(Field1,Field2), 'Yes', 'No')

The problem with this is that it also displays all incorrect values, essentially duplicating each result based on the number of entries in Field2.

E.g:

TrainingField1Field2Complete
ABCJohnJohnYes
ABCJohnPatNo
ABCJohnTomNo
ABCMikeJohnNo
ABCMikePatNo
ABCMikeTomNo

etc.

If I remove Field2 as a dimension from the chart, then it returns 'No' for all entries in Field1.

Is there a solution to have the chart display as I want above?

Thanks.

1 Solution

Accepted Solutions
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Colin,

given your data structure, you should be able to use something like this:

If(index('|' & concat(distinct Field2,'|') & '|', '|' & only(Field1) & '|')>0, 'Yes','No')

Make sure though that you only use Training and Field1 as your dimensions, otherwise you'll end up with the Cartesian join issue.

Marcus

View solution in original post

4 Replies
marcus_malinow
Partner - Specialist III
Partner - Specialist III

Hi Colin,

given your data structure, you should be able to use something like this:

If(index('|' & concat(distinct Field2,'|') & '|', '|' & only(Field1) & '|')>0, 'Yes','No')

Make sure though that you only use Training and Field1 as your dimensions, otherwise you'll end up with the Cartesian join issue.

Marcus

lironbaram
Partner - Master III
Partner - Master III

hi

this expression will work

if(wildmatch(Concat(Field2,','),'*' & Field1 &'*'),'YES','NO')

Anonymous
Not applicable
Author

Hi Marcus,

That worked perfectly. Thanks very much.

Much appreciated.

Declan

Anonymous
Not applicable
Author

That also worked Liron.

Thanks very much.

Declan