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: 
wanyunyang
Creator III
Creator III

value in field A=value in field B

I have table1 with fields item1 and category, table2 with item2. Now I'm creating a dimension to get category for item2 in expression editor.

I need some function like:

IF(item2=item1, category)

How should I do this?

Any advice helps. Thanks in advance!

1 Solution

Accepted Solutions
nagaiank
Specialist III
Specialist III

You may define a calculated dimension

If(item1=item2,item1) (uncheck 'include null values')

and define Only(cat) as measure

This worked for me

View solution in original post

4 Replies
nagaiank
Specialist III
Specialist III

If table1 and table2 are defined as follows, left joining table2 with table1 will give the required category (catforitem2) as seen below:

table1:

load * inline [

item1,category

1,cat1

2,cat2

3,cat3

4,cat4];

table2:

load * inline [

item2

2

3

];

left join (table2) load item1 as item2, category as catforitem2 resident table1;

HTH

wanyunyang
Creator III
Creator III
Author

Thanks for helping. Is there a way to do this in chart rather than in script?

nagaiank
Specialist III
Specialist III

You may define a calculated dimension

If(item1=item2,item1) (uncheck 'include null values')

and define Only(cat) as measure

This worked for me

avinashelite

As per me you don't need a condition also here, just rename the item2 in your script as item1 since they share the same data contain it will automatically gets picked !!