The HotDocs Computation Archive
Get Extra Help

0129 - COUNT a filtered dialog

Description:

How to obtain the COUNT of a filtered dialog.


• Code •

SET the count in a variable:

SET Count-n TO 0
REPEAT Repeated Dialog
   FILTER SomeFilter-c
   SET Count-n TO Count-n + 1
END REPEAT
 
 
Have the computation return the count:

0
REPEAT Repeated Dialog
   FILTER SomeFilter-c
   RESULT + 1
END REPEAT

• Explanation •

COUNT( Repeated Dialog ) will always return the full number of records (levels) in the dialog. This is unhelpful if you need to know only how many records there are in a filtered subset of the dialog.

To get a filtered COUNT, you must use one of the examples above. The first example places the count in a number variable, Count-n. The second example allows the computation itself to return the count.

A practical example is a table of Partners for a limited partnership. The table contains both general and limited partners. The following computation will return a count of limited partners only. It assumes a filter called LimitedPartnerFilter-c which contains the script: PartnerType-m = "Limited", where PartnerType-m is a multiple choice variable indicating whether the partner is general or limited.

REPEAT Partners
   FILTER LimitedPartnerFilter-c
   RESULT + 1
END REPEAT