Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
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!
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
What do you mean by recode value?
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?
in the table you have write if condition like : if ( sex =1 ,'Male','Female') as Sex
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?
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
Hmm...keep getting red squiggly lines under 'Male' and 'Female'.
may be due to fieldname...
make note that Sex, sex and SEX all are different fields..
So use the correct one.
That works to change the value labels for charts, but why won't it work for a Table Box?
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