If you would like to avoid arrays (I found them quite confusing when I
started with 4D) you could simply do the foll:

$nTotal:=0
$nDenom:=0

If ( [Table]n_a1 = False )
    $nTotal:= $nTotal +  [Table]Field1
    $nDenom:= $nDenom +1
End If

If ( [Table]n_a2 = False )
    $nTotal:= $nTotal +  [Table]Field2
    $nDenom:= $nDenom +1
End If

etc.

If ( $nDenom > 0)
   v_total:= $nTotal/ $nDenom
Else
  v_total:=0
End If

David Samson
Manchester
U.K.

From: Stephane Potvin <[email protected]>
> To: [email protected]
> Subject: Field calculations
> Message-ID: <[email protected]>
> Content-Type: text/plain;       charset=utf-8
>
> Hello all,
>
> This is likely a simple thing but, being an amateur in 4D, I am hoping
> someone can help me with a simple formula.
>
> My situation:
> I audition singers and grade them on up to 9 criteria.
> When all 9 criteria are used, the formula is simple:
>
> v_total:=([Table]Field1+[Table]Field2+[Table]Field3, etc.)/9
>
> However, in certain circumstances, I only need to calculate 8, or fewer
> criteria. To that end, I added a checkbox named “n/a”.
> What I trying to find is a way to calculate only those fields that are not
> marked “n/a”
>
> In other words, as I click “n/a” checkbox, I want the dominator of to be
> reduced by 1 each time.
> ie” one check: /8, 2 checkbox: /7, etc.
>
> I hope this makes sense and that someone has a simple solution.
>
> Thank you,
>
> Stephane
>
>
**********************************************************************
4D Internet Users Group (4D iNUG)
New Forum: https://discuss.4D.com
Archive:  http://lists.4d.com/archives.html
Options: https://lists.4d.com/mailman/options/4d_tech
Unsub:  mailto:[email protected]
**********************************************************************

Reply via email to