Default value in a variable when a section is disable

Hello Survey Solutions team

I have a new question.

I am doing somes calculus with variables but when I have a section disable my value in the variable is [...] like this pic:

I wish that my variable return zero (0.00) when the section is disabled.
Each variable is type double and the expresion for each variable is:

Math.Round((double)(Q1 + Q2 + Q3),2)

I am trying to do the following:

Math.Round((double)((Q1 + Q2 + Q3)??0.00),2) but when I compile this I have an error
[WB0027]:La expresión contiene un error de sintaxis this is because the operator ?? can’t be applied into a Integer and Double type.

Can somebody help me to resolve this?

Thanks for all your help.


Math.Round(new [] {Q1,Q2,Q3}.Sum(v => v!=null),2)

Hello Sergiy

I try your solution but give me this error:
[WB0027]: The expression contains a syntax error.

Can’t implicitly convert bool type to ‘long?’
The lambda expression cannot be converted to the indicated delegate type because some of the types of values ​​returned from the block cannot be implicitly converted into the type of value returned from the delegate.



Thanks Sergiy, this don’t give me any error.

But my problem persist, I continuos seen [...] in all that sections that are disables and I want to see zero when the section is disable.

Thanks for your help.

Your sum variable must be placed outside the section (Apartado X).

Because if the section is disabled, so are all the questions in that section, and so are all the variables! Survey Solutions does not calculate the values of variables in disabled sections. Hence their value is null (missing) and is displayed in text substitutions as […]. Also missing will be exported in the data.

As a side observation: it would be easier for the interviewers if the values were right-aligned (by centavos), and consistently formatted (two decimals for centavos in all values).

This would force me to have multiple variables (one for each member) where each of the variables will be the sum of each of the sections.I am using my sum variable within the (Member) section to use each member’s rowcode and I have a variable that sum all the values ​​reported by the member in each section (section).
For example (my actually work):
Member Jhon
Section1Total = Math.Round((double)new[]{section1Q1, section1Q2, section1Q3, section1Q4}.Sum(),2)
Section2Total = Math.Round((double)new[]{section2Q1, section2Q2, section2Q3, section2Q4}.Sum(),2)
Section3Total = Math.Round((double)new[]{section3Q1, section3Q2, section3Q3, section3Q4}.Sum(),2)

The total for the member Jhon is:
Total = Math.Round((double) new[{RosterHH[(int)HH_Rowcode].RosterMembers[@rowcode].Section1Total, RosterHH[(int)HH_Rowcode].RosterMembers[@rowcode].Section2Total, RosterHH[(int)HH_Rowcode].RosterMembers[@rowcode].Section3Total}.Sum(),2)

Just what I imagined, I assumed that since the section was not enabled the values ​​for each question and variable were null or some special value.

I would like to do it but it is somewhat complex since I don’t know the length of each of the variables (for example var1 = 1250.20 and var2 = 1), do you have an example to implement it?