Problem with sum of numeric items

Discussions about CSEntry
Post Reply
CMH
Posts: 31
Joined: April 1st, 2022, 1:54 am

Problem with sum of numeric items

Post by CMH »

Hi experts!!
Hope you are well.
I need to enter sum of 6 numeric items/variables (B16,C3, C5,C7, C9, C14) in another (D1) item/variables. Enumerator will calculate sum using calculator and enter in 7th item/variable. I also applied logic that if wrong total is entered, error message should appear so correct value may be rented. For that logic is:

if D1 <> B16+C3+C5+C7+C9+C14 then
errmsg("total is not correct. rechecking is required for B16,C3, C5,C7, C9, C14");
reenter;
endif;

Entering value in 6 items/variables are also subject to applicability depending upon other question, thus, i also applied skip logics that working properly. However issue is if one or more items/variables skip, the error message (total is not correct. rechecking is required for B16,C3, C5,C7, C9, C14) always appear while entering sum in 7th item/variable and it stocks. In case value is entered against all 6 items/variables, D1 works fine.

Kindly can you please identify what is issue and solution. Thanks!!
sherrell
Posts: 397
Joined: April 2nd, 2014, 9:16 pm
Location: Washington, DC

Re: Problem with sum of numeric items

Post by sherrell »

When a numeric field is skipped it's value is notappl. And you can't perform arithmetic with it at that point, it needs to have a numeric value. Therefore I suggest you set skipped fields to zero, which you can do as follows:

Code: Select all

PROC B16
// no logic here

PROC C3
preproc
if B16=1 then   // or whatever your skip condition was for B16
  $=0;
  noinput;  // keeps the variable on-path, but allows the enumerator to back up into the field--you probably don't want to allow this
endif;

PROC C5
preproc
if C3=1 then
  $=0;
  protect ($,true);	// keeps the variable on-path and does NOT allow the enumerator to backup into the field--you probably want to do this
else
  protect ($,false);  
endif;
https://www.csprousers.org/help/CSPro/p ... ction.html

Sherrell
CMH
Posts: 31
Joined: April 1st, 2022, 1:54 am

Re: Problem with sum of numeric items

Post by CMH »

Thank you Sherrel :) l.

Its not working, might be beacuse i didn't provide all/correct information :? :? . Following is additional information.

There is no logic applied on B16. However "ask" logics are applied on C3, C5,C7, C9, C14. These all will be appeared subject to responses in a multiple response item C1. Following logics are applied

PROC C3
PreProc Ask if pos("A", C1) > 0;
PROC C5
PreProc Ask if pos("B", C1) > 0;
PROC C7
PreProc Ask if pos("C", C1) > 0;
PROC C9
PreProc Ask if pos("D", C1) > 0;
PROC C14
PreProc Ask if pos("Z", C1) > 0;

Looking forward for the solution of mentioend issue in my previous post. Thanks!!
etuser
Posts: 86
Joined: September 3rd, 2019, 5:57 am

Re: Problem with sum of numeric items

Post by etuser »

if you specify the following at the preproc of the questionnaire , it might work.

PROC XXXXX_LEVEL
preproc
setproperty("SpecialValuesZero","Yes");
CMH
Posts: 31
Joined: April 1st, 2022, 1:54 am

Re: Problem with sum of numeric items

Post by CMH »

Hi etuser!!!
Thanks. Its working. :)
Post Reply