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.

Finding single occurence that fits a specific criteria

Featured Replies

  • Newbies

I haven't been able to work out the logic for the following search/find in my head, any suggestions?

Here's an example of a simple table

FIELD1 FIELD2

Red 2

Red 4

Green 4

Green 1

Green 5

Purple 1

Purple 4

What I want to be able to do is, find a single occurence for each value in FIELD1, but make sure that the single record found is the one with the lowest value in FIELD2.

For example, from the previous table, the filter would find this subset:

Red 2

Green 1

Purple 1

any ideas?

One way to do it involves adding a new relationship and a new calculated field. You would search for "1" in the new calculated field.

You would need to have a field "record_id" which is a unique identifier, e.g. an auto-generated serial number.

Add a new Table Occurrence with a new relationship.

Original Table on left hand side

New table "LowestColor" on right hand side

Field1 = Field1

Sort the right hand side by Field2 ascending

Create a new calculated field

IsLowestColor =

Case(

record_id = LowestColor::record_id; 1;

0

)

Search for 1 in IsLowestColor.

You haven't said how you want to results displayed nor the purpose of wanting this information. It would help to know whether you want the lowest 'red' value displayed when you are viewing red records or do you want to go to the lowest value? It also matters whether this is a one-time thing or an on-going process.

If you want to display the lowest red on red records and lowest green when viewing green records and this is on-going need then I would:

1) Create another table occurrence of your table (this is called a self-join). Simply click the ++ in the graph after selecting your table and name it.

2) Now join Main Table::Color = SelfJoin::color

3) Sort the selfJoin ascending on number. Display the selfJoin fields directly on your main layout (whatever information you want to display).

If you want to go to this 'lowest-this-color' record, script would be simple:

Go To Related Record [ from table self-join ; using CURRENT layout ] and do NOT check anything down in the 'Show Only Related Records' section unless you want to isolate all of one color in your found set.

  • Author
  • Newbies

Beautiful!

Works like a charm, Thanks!

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.