1 Reply Latest reply on Oct 30, 2008 9:27 AM by TSGal

    Summary Break Counting

    stanp

      Title

      Summary Break Counting

      Post

      Will (or does) Filemaker have a simple way to count the number of items (in my case it's clients or customers) in a summary report?

       

      In some cases, I'd also like to number the items in a summary report. How can that be accomplished?

       

      Stan P 

        • 1. Re: Summary Break Counting
          TSGal

          Stan P:

           

          Thank you for your post.

           

          One of the Summary field options is Count.  That is, it will count the number of records with an entry in that field.

           

          To do this, go into Define Fields, create a Summary field entitled "CountOfRecords".  When you click create, a new dialog box appears with the different options on the left side.  Click the option for "Count", and then select the field you want to "Count".

           

          When you say "number the items in a summary report", do you want a number for each grouping?  Or, do you want a new set of numbers for individual records in a summary group.  That is:

           

          Grouping A

             1 - Record 1

             2 - Record 2

             3 - Record 3

          Grouping B

             1 - Record 4

             2 - Record 5

             3 - Record 6

           

          or

           

          1 - Grouping A

          2 - Grouping B

           

          In either case, a script is the best way to accomplish this.  I'll accomplish both results in one script, and then you can decide which steps you need to remove to obtain the correct results:

           

          Enter Browse Mode []

          Sort [Restore; no dialog]

          Go to Record/Request/Page [First]

          Set Variable [$group; ""]

          Set Variable [$groupcount; 0]

          Set Variable [$subgroupcount; 1]

          Loop

             If [$group<>GroupField]

                Set Variable [$group; GroupField]

                Set Variable [$groupcount; $groupcount + 1]

                Set Variable [$subgroupcount; 1]

             Else

                Set Variable [$subgroupcount; $subgroupcount + 1] 

             End If

             Set Field [GroupCounter; $groupcount]

             Set Field [SubGroupCounter; $subgroupcount]

             Go to Record [Next; Exit after last]

          End Loop

           

          ========

           

          This sorts the file and goes to the first record.  We initialize a lot of variables and then look at each record.

           

          We evaluate the variable $group (which is blank) to the field you are grouping in the summary report.  In this example, that field is called "GroupField".  Since it isn't equal the first time, we set the variable to the GroupField and we increase the counter from 0 to 1 and set the subgroupcount back to 1.

           

          Once that is done, we set the GroupCounter field to the $groupcount variable, and the SubGroupCounter field to $subgroupcount variable and go to the next record.

           

          We go back to the top of the loop, evaluate the variable $group to the GroupField, and if it is equal, then we just increment the $subgroupcount field by one and continue on.  When the GroupField changes, the $groupcount field is incremented by 1, and the $subgroupcount field is reinitialized back to 1.

           

          I hope this makes sense.  If you need clarification for any of the above steps, please let me know.

           

          TSGal

          FileMaker, Inc.