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

Compare two fields in a chart

I have two fields  of IDs : IDA and IDB I want to compare in a chart. If value of IDA appears in IDB, then mark it valid. The chart should look like this. I think there should be an expression I can write for the "Valid" column, can someone help with that?

Thanks

IDA

Valid

251243

Yes

12613

NO

1543

Yes

7 Replies
maximiliano_vel
Partner - Creator III
Partner - Creator III

Can you send the IDB values?

Anonymous
Not applicable
Author

For example:

251243,

12612,

1543

maximiliano_vel
Partner - Creator III
Partner - Creator III

Try this

FieldsTmp:

LOAD * INLINE [

  IDA, IDB

  251243, 1543

  12613, 251243

  1543, 12612

];

ToCompare:

LOAD IDB as CompareTo

RESIDENT FieldsTmp;

NOCONCATENATE

Comp:

LOAD IDA,

     IDB,

     if(Exists(CompareTo, IDA), 'Yes', 'No') as Valid

RESIDENT  FieldsTmp;

DROP Table FieldsTmp, ToCompare;

Anonymous
Not applicable
Author

Anyway this can be done in the chart instead in the load script? I was trying to avoid using load script because there are a lot of fields I'm trying to compare. I feel an expresison in the chart will be easier.

thanks

maximiliano_vel
Partner - Creator III
Partner - Creator III

If the columns IDA and IDB are like

IDAIDB
1234512345
12621263
34253425

Then the Valid Column shoud be something like

=f([IDA]=[IDB], 'Yes', 'No')

Anonymous
Not applicable
Author

Actually, IDA and IDB are fields from two differnet tables. How should the expression be modified?

Thanks

Kushal_Chawda

Create calculated dimesion

=aggr(if(trim(lower(IDA))=trim(lower(IDB)),'Valid','Invalid'), Dimension)

or Expression

if(trim(lower(IDA))=trim(lower(IDB)),'Valid','Invalid')