Andy Hayden
Andy Hayden

Reputation: 375455

Counting instances of same field entry

I have a Filemaker table with multiple entries in fieldA, how can I set fieldB to count the number of occurrences of the corresponding number of records which have the same value in fieldA.

For example, if fieldA is a;b;b;c I want fieldB to read 1;2;2;1.

Upvotes: 0

Views: 2712

Answers (2)

Sam Barnum
Sam Barnum

Reputation: 10714

You'll want a recursive custom function which you pass the fieldA contents in to.

It takes as parameters:

  • the text being parsed
  • the current position being parsed (starting at 1)
  • the output text being built

grab the fieldA value (e.g. "a") at the supplied position, then count the number of occurrences of "a" in the text being parsed. Append this to the output text, then if there are more values to process, call the recursive function again, with an incremented position, returning the result. Otherwise, return the output text.

Upvotes: 0

Mikhail Edoshin
Mikhail Edoshin

Reputation: 2669

The simplest is to make a self-relationship from the table to another occurrence of the same table by fieldA. Then fieldB can be like Count( sameFieldA::fieldA ).

Upvotes: 1

Related Questions