Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How do I recode values of my variables?

Hello!

I have a variable ("sex") and the values are numeric - 1 for Male, 2 for Female. I want them to display in my table as the strings "Male" and "Female", not 1's and 2's. I have found a lot of guidance as to renaming the variable, but what I want to do is relabel the values of my variable. Is there a way to do this with script (or even point-and-click), and if so, where would I put it?

Thank you!

1 Solution

Accepted Solutions
rupamjyotidas
Specialist
Specialist

You need to make the change in Script and use the New field in Table Box.

IF(Sx = 1, 'Male', IF(Sx = 2,'Female','NA')) as Sx2

View solution in original post

11 Replies
MK_QSL
MVP
MVP

What do you mean by recode value?

Not applicable
Author

I guess I am not using the correct term. I wan to "recode" the 1's and 2's as "Male" and "Female". Does that make sense?

muniyandi
Creator III
Creator III

in the table you have write if condition like : if ( sex =1 ,'Male','Female') as Sex

Not applicable
Author

I am more familiar with Tableau - in Tableau, I would be able to create a calculated field that said something along the lines of [if sex = 1 then "male" elseif sex = 2 then "female" else null] and the 1's and 2's would display as "male" and "female". I am wondering if there is something similar I can do in QlikView?

MK_QSL
MVP
MVP

I think you mean you have fieldname Sex and having values 1 and 2

You can do something like below in script.

IF(Sex = 1, 'Male', 'Female') as Sex

Not applicable
Author

Hmm...keep getting red squiggly lines under 'Male' and 'Female'.

MK_QSL
MVP
MVP

may be due to fieldname...

make note that Sex, sex and SEX all are different fields..

So use the correct one.

Not applicable
Author

That works to change the value labels for charts, but why won't it work for a Table Box?

rupamjyotidas
Specialist
Specialist

You need to make the change in Script and use the New field in Table Box.

IF(Sx = 1, 'Male', IF(Sx = 2,'Female','NA')) as Sx2