3 Replies Latest reply on May 31, 2016 11:36 AM by TSGal

    Function: Count()


      FMPro Adv 14 and 15

      Windows 10

      all with latest updates


      The function Count() returns wrong results when used in a script counting repeating fields and non repeating fields.


      I found different results using the function Count() in a calculated field and in a script.

      I replicated the example that is present in the manual of the function.

      The calculated field has the correct results, where the calculation in the script add 1 to the results in all repetition except the first one if there is a non empty non repeating field in the calculation, i.e:

      Count(Table::f1;Table:F2;Table;F3) where F2 is a non repeating field.

      If the non repeating field is empty, the result is correct.

      See the attached example.

        • 1. Re: Function: Count()



          Thank you for your post.


          The calculation "R Calculated" is already based on a repetition.  The script is capturing a calculation, and then placing that result in a repetition.  Therefore, change your formula to extract the specific repetition you want to count before placing the result in the desired repetition in "R".  That is, change your script as follows:


          Set Field [ test repetition::R ; Count ( R1 ; R2 ; R3 ) ]

          Set Field [ test repetition::R[2] ; Count ( R1[2] ; R2[2] ; R3[2] ) ]

          Set Field [ test repetition::R[3] ; Count ( R1[3] ; R2[3] ; R3[3] ) ]

          Set Field [ test repetition::R[4] ; Count ( R1[4] ; R2[4] ; R3[4] ) ]



          FileMaker, Inc.

          • 2. Re: Function: Count()

            Thank you TSGal,

            but that is not what the manual says (FileMaker Pro 15 Help ):

            the formula is:

            Count(Field1;Field2;Field3) returns 3, 2, 1, 1 when the calculation is a repeating field.


            So, or the Count function does not work as expected, or the manual is wrong.



            • 3. Re: Function: Count()



              "R Calculated" is a calculated repeating field.  The example is correct and will return the correct value.


              "R" is not a calculation, but a repeating field.  However, I would expect the same value (3) in each instance of the repetition since you are obtaining the first repetition value of fields F1, F2 and F3 and placing that value in each of the repetitions of "R".  I have sent this information to our Development and Testing departments for review.  When I receive any feedback, I will let you know.



              FileMaker, Inc.