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.

Pulling Single Value out of a Related Table

Featured Replies

I'm working on developing a database for habitat surverys. We collect multiple measures for each category (i.e. Substrate: silt, gravel, pebble, rock, leaves), but in the end are just interested in the average percent of the site that each type covers. To minimize error, the hope is for raw, unaveraged data to be entered into the table, and have FM do the averaging by subtype and spit that out in a master table (Habitat).

Right now, the data is being entered into a portal, and the weighted average is a calculation field in the same table (sum of substrate type/number of samples taken) determined via a self-relate. So if there are 5 silt entries for one site, this average is reported in each of them.

Is it possible for FM to select the average for each category and spit it out into a specific field in the overall Habitat table?

I'll try to upload the database for clarification, but I'm having problems with that right now.

What version of FM? this sounds like a possibility with Filtered portals and ExecuteSQL (FM12).

You should be able to extract the data with a script by looping through the records in the portal. Then for each unique substrate type found you would save the average.

You could also view the information using sub-summary part(s) in preview mode.

See if this helps: a script generates two list, loops through them and generates one finished list with names and averages. The relationship (not the portal!) needs to be sorted by substrate name. With FM 10 and newer, you could use Set Field by Name to write the values programmatically into dedicated fields.

While this approach may work, I suggest setting up tables like Categories and SubTypes and recording all your measurements in one Measurement table; this gives you a much more flexible tool to generate reports by habitat, date ranges, sub-types and/or categories, and you only have to write reporting scripts and set up layouts once.

FLW_HelpTest_LoopingScript.fp7.zip

  • Author

What version of FM? this sounds like a possibility with Filtered portals and ExecuteSQL (FM12).

FM 11 Pro Advanced

Please update your profile properly by using this quick link. Profile

  • Author

EOS, thanks for you help and for the script! One follow-up question -- the substrate types are not neccessarily entered in order (i.e. sand, sand, rock, silt, sand). I have been trying to include a sort line, but to no avail. Do you have any suggestions?

Thanks again!

Not sure what you mean. The substrate types are sorted in the portal; where else do you want them to be sorted?

  • Author

Oops, I missed that key, very obvious part of your post about the relationship being sorted. Thank you!!

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.