Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

I have a table with about 100,000 records. One of the fields in the table is called "DecimalNumber" (type is "Number").

There are many records (perhaps 10 to 20%) which have the same value in that field as another. Sometimes only 2 records have common values, sometimes more.

What I want to do is to delete all records except one of each of those which share a value, thereby removing 'duplicates'.

How do I achieve this? I assume a script will be needed, if so please can you give me the whole of that script.

Many thanks in anticipation.

Edited by philipcaplan

Off the top of my head, without testing it at all, which means don't just write it and trust it. Try it on a backup copy of your database first:

Show All Records
Sort Records [table::DecimalNumber]
Go to Record/Request/Page [ First ]
Loop
  If [ $_number = table::DecimalNumber ]
    Delete Record/Request [ No dialog ]
  Else
    Set Variable [ $_number ; table::DecimalNumber ]
    Go to Record/Request/Page [ Next ; Exit after last]
  End If
End Loop

 

Try:

# FIND DUPLICATES 
Enter Find Mode [  ] 
Set Field [ YourTable::DecimalNumber; "!" ] 
Perform Find [  ] 
# SORT BY THE DecimalNumber FIELD 
Sort Records [ Restore; No dialog ] 
# DELETE DUPLICATES 
Go to Record/Request/Page [ First ] 
Loop 
 If [ YourTable::DecimalNumber ≠ GetNthRecord ( YourTable::DecimalNumber ; Get ( RecordNumber ) - 1 ) ] 
  Go to Record/Request/Page [ Next; Exit after last ] 
 Else 
  Delete Record/Request [ No dialog ] 
 End If 
End Loop 
# 
Show All Records 

 

Edited by comment

  • Author

Hi comment.  

(1) Where you have "Get(RecordNumber)-1" are you assuming I have a 'unique serial number' called RecordNumber which I can use, because I'm afraid I don't. The dataset came from an outside tab-separated file which I opened in FMPro, and did not have any such numbering.

(2) Or, is "RecordNumber" something that FMPro will understand as being an internal number in sequence?

(3) If not, it seems to me that the only way a script can know if two records contain a duplicate value for DecimalNumber is if the Next Record's value for DecimalNumber is the same as the current record, in which case either one or the other can be deleted.

(1) Where you have "Get(RecordNumber)-1" are you assuming I have a 'unique serial number' called RecordNumber which I can use, because I'm afraid I don't.​

No. Get(RecordNumber) is a Filemaker function - look it up.

  • 3 years later...
  • Newbies
On 6/16/2015 at 4:21 AM, comment said:

Try:


# FIND DUPLICATES 
Enter Find Mode [  ] 
Set Field [ YourTable::DecimalNumber; "!" ] 
Perform Find [  ] 
# SORT BY THE DecimalNumber FIELD 
Sort Records [ Restore; No dialog ] 
# DELETE DUPLICATES 
Go to Record/Request/Page [ First ] 
Loop 
 If [ YourTable::DecimalNumber  GetNthRecord ( YourTable::DecimalNumber ; Get ( RecordNumber ) - 1 ) ] 
  Go to Record/Request/Page [ Next; Exit after last ] 
 Else 
  Delete Record/Request [ No dialog ] 
 End If 
End Loop 
# 
Show All Records 

 

Thanks. Work for my table. 

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.