Enter a number, output a character

1. What is the problem? Be very detailed.

I am using a numeric keypad to enter data in inclement weather. We are attempting to touch the tablet screen as little as possible. I would like to enter the sex of a species as either 1,2, or 3 in an integer type question and have the output after data download appear as a character either M,F, or U.

2. What app or server are you using and on what device and operating system? Include version numbers.

Using xlsforms to design the form and kobotoolbox to deploy the html form.

3. What you have you tried to fix the problem?

Have tried if then statements in the calculation field but can't seem to get the form to function with these.
For example: if(${Sex}=1,${Sex}=M) or if((${Sex}='1','M',if(${Sex}='2','F',if${Sex}='3','U')

4. What steps can we take to reproduce the problem?

5. Anything else we should know or have? If you have a test form or screenshots or logs, attach below.

Why don't you use a select one question?

I had thought about that, but select one involves more interaction with the number pad and potentially the touchscreen.

I think it's just 1 touch on the screen, which is the least.

Thanks @Trung ! Any other ideas here to the original question? I'd still prefer to input a number from the 10 key pad and output a letter.

I think the simplest solution is to transform the data in the backend.

Using a numeric keypad in this context makes a lot of sense. This is a requirement that others sometimes have -- it would be helpful if you could share the make and model of the device you're using.

To do what you're trying to, you'll need two separate fields. It sounds like you already have the integer question set up as you want. I'll assume it has name sex_input below but you can name it whatever you want. The second will be a calculate and could be named sex, for example. Its calculation will look something like

if(${sex_input}=1, 'M', if(${sex_input}=2, 'F', 'U'))

It looks like your second attempt was close but you had parentheses in the wrong place. Note that if your first question has a constraint to only allow values 1-3, you don't need to explicitly check for the 3 case and can output 'U' as long as neither 1 or 2 was matched.

You can review the if structure in the documentation.

This is great @LN, thank you for your input.
FYI I am using Panasonic Toughpad FZ-M1 tablets. They are quite rugged but seem to be prohibitavely expensive. I would not recommend them and would use a less expensive tablet with waterproof case in the future. Also, they do not run Android which necessitates the use of HTML form instead of using ODK collect.