Negative answers in numeric questions

User Rosina has sent us the following question:

How to limit the system to allow only Whole Numbers (only positive numbers) not by using the validation rules? Because currently, the system allows Integers and real numbers only which both can take either negative or a positive number

Depending on what this number means in your survey, you can try to use a text field with a digits-pattern, e.g. ##### for 5-digit numbers.

Thank you for the response Sergiy, but I don’t think using a text field will work if I will be using the same number in calculations.
For example: number of employees whereby you will have to use the same number into validation to check if the average income for the employees is within some certain range


The typical solution is not to use the text field of course, but equally the typical solution is to use a validation to ensure the number of employees is not negative, but you’ve explicitly ruled that out in your question:

I am trying to avoid the validation rule in setting up the number to be positive because I will be having a lot of question that requires only whole number, so setting a validation for each of these questions will increase the capacity of the questionnaire so that is what I am trying to avoid. So I am trying to reduce the number of validation rules where ever possible

Just in case you need it:

Create a Text question (say, “numEmployees”) with pattern ### as Sergiy indicated and you will always get a positive integer.
Now create a Long Integer variable (say “nEmp”) with the expression: Int32.Parse(numEmployees).
Use nEmp in your calculations.

Thank you for that suggestion. In my case, I have more than 20 of such kind of variables which means I will have to create 20 more for the conversion and my worry was trying to limit the space since my questionnaire is very long

Hi Rosina,
I wouldn’t worry about the space for these variables, they should occupy next to nothing.

Best regards,

1 Like

The space does matters because my questionnaire is almost 5mb when I add more things it gets over the maximum capacity which is 5mb

Okay, in all the surveys I have participated in we never reached a total qx size limit.
Maybe someone from the SuSo developer team can comment on this.
How many thousands of questions do you have?
Did you have someone take a look at your qx?

I have a total of about 670 questions and 8 rosters, and yes someone has already looked at it

Maybe you can use a macro like this

And then just call your macro and define the error text.

This questionnaire size definitely should not exceed 5mb limit. Usually such big sizes exist due to the large list of categories (can be resolved by using reusable categories). Could you please share with us what actually makes your questionnaire that big?

There is actually quite hard to achieve 5Mb limit using only questions, only way I’m aware of - is to use multiple categorical questions with lot of options.

Move those categorical options to reusable categories

Reusable categories are not accounted into questionnaire size limit.

1 Like