2 Replies Latest reply on Jun 13, 2012 5:28 PM by AnitaWoods

    PatternCount... won't



      PatternCount... won't


      I am an novice user with a Contacts table listing mother's name, and a Birth table listing one record for each of her children.  Contacts is related Contacts::ContactID = Birth::ContactID to a second occurrence of the Birth table. I have the following calculated field in the Contacts table, counting how many cesareans she's had from the Birth::BirthOutcome field:

      PatternCount (Birth 2::Birth outcome ; "CS") + PatternCount (Birth 2::Birth outcome ; "ERCS") + PatternCount (Birth 2::Birth outcome ; "RCS")

      It seems to only be counting one, no matter how many births she has in the Birth table with more than one.  What am I doing wrong?

        • 1. Re: NoFields

          I would assume there is one Birth record for each birth.

          If so, then your expression is only accessing the data in the first related record. To count the values in multiple records would require a different approach.

          One option is: PatternCount ( List (Birth 2::Birth outcome ) ; "CS" )

          but please note that such an expression will count the "CS" in CS, ERCS and RCS so you may need to rethink how you are counting these.

          • 2. Re: NoFields

            As usual Phil, you come through.  This works perfectly, because I don't need a count of each one, I need a count of the total times any of those three appears.