Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. IMPORTANT DETAILS
cancel
Showing results for 
Search instead for 
Did you mean: 
williamhayes
Contributor
Contributor

Assigning a single value based on different field values but sharing the same key

Hello, 

I am new to Qlik sense.

I have this logic that if the key is the same and it has value for Variable1 (blue, purple) then assign 'Colors' to variable2, same goes for (cat, dog), assign animals.

Can this be done in Qlik sense, if so, how? 

Key Variable1 Variable2
1 Blue Colors
1 Purple Colors
2 Cat Animal
2 Dog Animal
3 Blue Sky
4 Dog Pet

 

Many thanks for the help.

Labels (5)
3 Replies
sidhiq91
Specialist II
Specialist II

@williamhayes  May be you can try something like below:

Mapping_table:
Mapping load * inline [
Variable1, Variable2
Blue, Colors
Purple, Colors
Cat, Animal
Dog, Animal
];

Temp:
Load Key,
Variable1,
ApplyMap('Mapping_table',Variable1,'Not found') as Variable2

inline [
Key,Variable1
1, Blue
1, Purple
2, Cat
2, Dog

];

exit script;

You might need an extra table to do the mapping.

williamhayes
Contributor
Contributor
Author

@sidhiq91 Thanks for your input. I have updated my question.

What about the combination? Only when Blue and orange in the same key can be assigned 'colors', will the mapping still works?

Let's say for

Key 1 [Blue, Orange] = Colors,

Key 3 [Blue]=Sky

Apologies for the confusion.

sidhiq91
Specialist II
Specialist II

@williamhayes  Yes it would still work provide we do not have ',' in between Blue and Orange:

You can provide some sample data for me work around if required.