Skip to main content
Announcements
Announcing Qlik Talend® Cloud and Qlik Answers™ to accelerate AI adoption! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Rename variable's value in Qlikview


Hi All,

I am trying to rename to the variable's values in Qlikview. May I know how to go about doing it? I had tried using "if" and "Rename"  function but it doesn't seems to work.

For example

OriginalDesired Output
MonTueWedThuFri=>MonTueWedThuFri
FruitsappleorangebananapeargrapesFruits12345

My expression:

if(Fruits='apple','1') or

if(Fruits='orange','2') or

....

if(Fruits='grapes','5')

1 Solution

Accepted Solutions
Not applicable
Author

Otherwise, if you are just looking for a nested if-statement expression to evaluate the 'Fruits' text to numeric, you can do something like this:

If(Fruits = 'apple', 1,

     If(Fruits = 'orange', 2,

          If(Fruits = 'banana', 3,

               If(Fruits = 'pear', 4,

                    If(Fruits = 'grapes', 5)))));

View solution in original post

5 Replies
Not applicable
Author

I am not sure what you are trying to do. Do you want to rename the values during the script loading? Also, do you only have a few values (i.e. like 5-6) that you want to convert to numbers?

One approach might be do use WildMatch() like this:

LOAD WildMatch(Fruits,'apple','orange','banana','pear','grapes') as Fruits

FROM Table;

If Fruits = apple, WildMatch will return a 1

If Fruits = orange, WildMatch will return a 2

and so on...

Not applicable
Author

Hi Lior,

Thanks for your reply. I am actually try to rename the variable values into names easier read by user. The initial variable value is a code  X82-123 which I want to rename to be easier read value "apple".

I do not want to convert to number. I had around 15 values to convert.

Best regards,

Andy

Not applicable
Author

Otherwise, if you are just looking for a nested if-statement expression to evaluate the 'Fruits' text to numeric, you can do something like this:

If(Fruits = 'apple', 1,

     If(Fruits = 'orange', 2,

          If(Fruits = 'banana', 3,

               If(Fruits = 'pear', 4,

                    If(Fruits = 'grapes', 5)))));

Not applicable
Author

Thanks Lior!! It works now!

Cheers,

Andy

Not applicable
Author

You may want to look into ApplyMap(). You can load or create a table of code -to- friendly values.

For example:

// Code to Friendly values:

Map_Fruits:

Mapping LOAD * Inline

[

  Code,Values

  1,apple

  2,orange

  3,banana

  4,pear

  5,grapes

];

// ApplyMap when you load your data:

YourTable:

LOAD ApplyMap('Map_Fruits', Fruits) as FriendlyFruits

FROM Table;