How to consolidate/count/tally survey results

I am doing this survey database. The respondent’s survey form isweb-based. The survey is a series of 105 questions with only 2

choices. A respondent has to select which of the 2 choices is

important to him. Like this:

  1. a. Good fringe benefits

    b. Pleasant work environment

  2. a. Salary/wages

    b. Recognition of others

I’ve rendered this as a radio button so that the respondent must

choose only one of the 2 factors.

The completed form will then be stored in a Notes database. So far, I

have no problem with the submission of the form, because its only

straightforward.

Each question corresponds to a factor like in #1 choosing “a”

corresponds to factor S1 and choosing “b” corresponds to factor B2, in

#2 choice “a” is S2 and choice “b” is P1.

In each radio button choice, I placed an alias corresponding to the

factor code. Like, Good fringe benefits | S1

        Pleasant work environment | B2

So for #1 the contents of the field would either be S1 or B2.

So far so good? :slight_smile: Is what I am doing right so far? :slight_smile:

Here’s my dilemma. How do i count the results?

I created a table with fields corresponding to the factors. All were

computed number fields with compute after validation checked. Then in

the Value object I placed an @formula:

@IF(One=“S1”;S1_c = S1_c + 1;B2_c = B2_c + 1);

@IF(Two=“S2”;S2_c = S2_c + 1;P2_c = P2_c + 1);

I placed these formulas in the fields of the factors affected.

Apparently, this way didn’t work. I’d like to solicit your suggestions

on how to approach this.

I downloaded a survey database from the Sandbox, but it was only a

straightforward counting and the counting was done in LotusScript.

Unfortunately, my LotusScript skills is sorely lacking.

I would really appreciate any help in this. Thank you very much.

Subject: how to consolidate/count/tally survey results

i’ve just discovered that the domino server where my survey database resides in is R5.0.7, and i am designing this database using R6.5.1!

after i post this, i will move the database to a server with ND6.5.1 :slight_smile:

i’ll keep you posted. thanks… :slight_smile:

(finally i am seeing a light in the tunnel! :slight_smile: )

Subject: @dblookup doesnt work when i moved to R6 server

the @dblookup is now the one not working after i moved the database. i also moved the other database, where the survey database looks up.

i didnt change the formula.

server := @Subset(@DbName;1);

x := @DbLookup(“Notes”:“NoCache”;server:“Employee.nsf”;“Active Employees”;empictrl;2);

@If(@IsError(x); “error in lookup”;x)

the survey database looks up the employee name from the employee database with the employee number as the keyword.

this worked fine in the R5 server. do i have to restart the server?

Subject: RE: @dblookup doesnt work when i moved to R6 server

@DbLookup works no differently in ND6 than in other versions. Your @IsError test is hiding the error message that might tell you what’s going wrong. Suggest you change it to @If(@IsError(x); @Text(x); x). I’m guessing that the database you’re looking up to doesn’t exist on the new server.

Subject: RE: @dblookup doesnt work when i moved to R6 server

It said “You are not authorized to access the view.”

Subject: RE: @dblookup doesnt work when i moved to R6 server

And can you open the view in your Notes client?

It sounds like the view has a Readers list, and whatever ID you’re using to do your testing, doesn’t have access to use the view. There are a couple of ways this might happen:

The replica or copy of the database you’re looking up into on the new server isn’t the same as on the old server (e.g. you’re a member of a given role on one server, but not on the other).

The database ACL is the same, but the view readers list uses a group name, and you are not a member of that group on the new server.

The database ACL is the same, the view readers list uses a role name, the database ACL contains a group name which is a member of that role, and you are not a member of that group on the new server.

Subject: RE: @dblookup doesnt work when i moved to R6 server

Hi! the database is working now. :slight_smile: thanks for everything :slight_smile:

Subject: how to consolidate/count/tally survey results

I’m not even going to try to understand the logic of your formula, but at least I can tell you why it’s not working. In Notes Formula, you cannot say something like you have … S1_c=S1_c+1

You must use @Set(“S1_c”;S1_c+1) and so on.

Subject: RE: how to consolidate/count/tally survey results

Henry’s not correct about @Set; you can use something of the form a := a + 1 (note the colon). However, it’s not clear what you’re trying to accomplish, based on what names you’re using in your assignments. Variables set in this way are temporary values that are erased when the formula execution is complete.

So assign fields, you have to use the FIELD statement or @SetField. Or, with a computed field formula, the value of the last value-returning statement is the value assigned to that computed field.

It seems that you want a series of computed fields that contain, what, the number of times that factor was chosen over something else? If you want to do this with separate computed fields, you could write a lot of @If formulas in each field, but then you end up testing each field multiple times, and you have a lot of code to maintain. Changing the questions is difficult because many formulas may be affected. This seems like something best done with some kind of central formula or script. Since it’s a web application, you could use JavaScript for validation (to make sure they select a value in each field), and either a WebQuerySave agent or a single formula that loops thru the fields and assigns them all.

E.g. let’s say that your total fields are named A1, A2, B1, B2, S1, etc – in other words they are named the same as the values to found in the checkbox fields. And let’s suppose that the checkbox fields are named CK_1 thru CK_105. You might write something like this in a webquerysave:

Dim doc As NotesDocument

Dim totalsList List As Integer

Dim factorsArray As Variant

Dim strSelection As String



Set doc = session.DocumentContext



' make sure we have a total for each of the factors in the survey, initially 0

factorsArray = Split("A1,A2,B2,B2,B3,S1,...", ",")

Forall factorTemp In factorsArray

	totalsList(factorTemp) = 0

End Forall



' scan thru the checkbox fields and count up which value was chosen.

Set doc = Source.Document

Forall item In doc.Items

	If Left(item.Name, 3) = "CK_" Then

		strSelection = item.Values(0)

		' assume the value in the field is valid (it was checked in onsubmit)

		totalsList(strSelection) = totalsList(strSelection) + 1

	End If

End Forall



' assign each of the total fields.

Forall intTotal In totalsList

	Call doc.ReplaceItemValue(Listtag(intTotal), intTotal)

End Forall

There are other ways to do this. Something similar could be done in JavaScript using the document object model there. Or you could write a formula using @For and @DocFields to loop through your checkbox fields and count up the values. This formula could be in a Computed for Display field – make your totals fields computed when composed with a formula of 0.

Subject: how to consolidate/count/tally survey results

Its running as expected. :slight_smile: thank you very much for all the help. :slight_smile:

Subject: how to consolidate/count/tally survey results

thanks for the code … :slight_smile: i really appreciate it. :slight_smile:

i placed it in an agent on the webquerysave object of the form.

the total fields are “computed when composed” with a field value of 0.

when the form is submitted. the totals appear 0. is this because i placed a field value of 0? what type should the total fields be?

i’m really at a loss here now. thank you very much for your time.

Subject: RE: how to consolidate/count/tally survey results

when the form is submitted. the totals appear 0. is this because i placed a field value of 0?No, it’s because there’s a problem with your Webquerysave agent code.

Add these lines:

Dim session As New Notessession

On Error Goto Errortrap

Option Declare

(then, at the end of the Initialize sub)

Exit Sub

Errortrap:

Print "Error " & Err & " line " & erl & ": " & Error

exit sub

This should tell you where the problem is.

what type should the total fields be?

Number

Subject: RE: how to consolidate/count/tally survey results

Hi! Thanks again … Here’s the error:

Error 233 line 13: Operation not supported in this version

this is line 13: factorsarray = Split(“P1,P2,P3,S1,S2,S3,B1,B2,B3,E1,E2,E3,A1,A2,A3”,“,”)

I am not really well versed in LS, please bear with me.

Thank you very much.

Subject: Error 233

The error 233 happens when you use an R6 function or feature on an R5 server. You’ll have to code your own splitR5() if you cannot find one.