Long Validation condition

I have 9 questions asking on harvest and deductions of the harvest. Lets say a total harvest of 21 tons is provided by the first questions asked and the following deductions are given as answers (see variable names for the valdiation condition below as well):

Total harvest: 21 tons (vol_1_1)
Sold: 18 tons (sol_1_1)
Kept for HH consumption: 2 tons (con_1_1)
Given to relatives: 0.8 tons (con_re_1_1)
Still in stock: 0 tons (sto_1_1)
Kept for seed: 0 tons (se_1_1)
Wasted: 0.2 tons (wa_1_1)

I have added the following validation condition in order to check that non of the deductions of the 8 particular variables exceeds the total harvest (vol_1_1). The condition works for all cases except the case when wa_1_1 (having 0,2 tons left) matches 0,2 tons:

wa_1_1<=((vol_1_1??0)-(sol_1_1 ??0)-(con_1_1??0)-(con_re_1_1??0)-(sto_1_1??0)-(se_1_1??0))

Any advice?

Where is a roster in this whole design? What you described doesn’t mention the roster at all.

Could you please extract just that group of questions into a new questionnaire, import to demo server, and replicate with the same inputs? I don’t see why this would not work.

Is it also the same when you have integers for inputs?

1 Like

Thank you @sergiy. My bad, its not a roster question. I have followed your advice by applying an demo export, however, the issue remains. I have created an example here: https://designer.mysurvey.solutions/questionnaire/details/0de987d2-4d54-4daa-83a3-959d6ab8816b

Here is how this appears from Stata’s perspective:
image
Now it should be obvious!

1 Like

@sergiy, ok thanks. I get the example from STATA, but why is it distinguishing between the second decimal place?

because the calculations are done by a computer, not a person. See around this page:

1 Like

@zepmaya, Use the Math.Round() method to round the value in 2 digits, as below:

wa_1_1<=Math.Round(((vol_1_1??0)-(sol_1_1 ??0)-(con_1_1??0)-(con_re_1_1??0)-(sto_1_1??0)-(se_1_1??0)),2)

1 Like