Jay
Jay

Reputation: 6638

Get statistic of record counts from FileMaker using AppleScript

Can somebody advise whether there's a good built-in way (= AppleScript command) to pull out statistics for a DB:

I need to count the number of occurrences of a string in a particular field over all records.

E.g. for a record that has

the script would return how many records exist with identical towns.

Upvotes: 1

Views: 426

Answers (2)

Ted
Ted

Reputation: 2239

Step 1 - Create a relationship. - File > Manage Database > Define Database - Relationships tab - Duplicate your table occurance and name it (I used related_towns) - Drag a relationship between the two from town to town - Click OK.

This is what your relationships tab should look like

Step 2 - Create a calculated field that counts the instances of the related (duplicative) town name.

  • File > Manage Database > Define Database
  • Fields Tab
  • Type in the name of your new field (I used number_of_related_towns) at the bottom of the screen
  • Select "Calculation" from the field type list
  • Count the times that the town appears in your relationship with this calcuation:

This is what your calculation field should look like

Be sure that "Evaluate this calculation in the context of" is set to the name of your base table (what your layout is based on). Replace related_towns with whatever you named your new table occurance.

Step 3 - Write a script to display your data.

  • Scripts > Manage Scripts
  • New button (bottom left)
  • Rebuild the screenshot below. I added comments, which hopefully explain?

enter image description here

Let me know if you have any questions.

Upvotes: 2

Ted
Ted

Reputation: 2239

I would do this in FileMaker. It is built for exactly this. Do you know how to do it in FM?

Upvotes: 0

Related Questions