Qlik Community

New to Qlik Sense

Discussion board where members can get started with Qlik Sense.

wanyunyang
Contributor

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
Valued Contributor III

Re: value in field A=value in field B

You may define a calculated dimension

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

and define Only(cat) as measure

This worked for me

4 Replies
nagaiank
Valued Contributor III

Re: value in field A=value in field B

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
Contributor

Re: value in field A=value in field B

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

nagaiank
Valued Contributor III

Re: value in field A=value in field B

You may define a calculated dimension

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

and define Only(cat) as measure

This worked for me

Re: value in field A=value in field B

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 !!