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.

picking the 3 best grades from a course linkup table

Featured Replies

Dear experts,

 

I've got a student table linked via a linkup table to 3 or more courses in a 3rd table (see screenshot). The linkup also contains the grades.

 

I've been chewing on the following calculation: calculate an average of the 3 best course grades, e.g. discarding the worst if a student took 4 courses. So, I have to collect the grades via the student ID and then discard the worst if more than 3.

 

I've already burned 2h hours on this since I'm not very familiar with FM. I hope somebody can help me out.

 

All the best,

post-109844-0-66552100-1382459686_thumb.

Solved by comment

Go to solution

One way to do this is by sorting the related records from the join table by grade, descending (you do this in the relationship setup). Then you can use the GetNthRecord() function in the Students table to get the first three related records and calculate their average.

I remember a similar requirement for sporting events, but wasn't able to locate it. See if this example helps you …

 

EDIT: Saw comments post after posting myself; his method and description should be all that's necessary.

  • Author

Hi comment, hi eos,

 

Thanks for answering. Sorted the relationship - check.

Retrieved the grades in order using GetNthRecord() - check. I did this In separate fields to test. The command below correctly retrieved 1.0 as the best grade in a 1st, 2nd, 3rd system out of the following series: 1.0, 1.2, 1.4, 2.0.

GetNthRecord ( module allocation::module grade ; 1

Then, I attempted the following computation of the average of the 3 best grades:

Average ( GetNthRecord ( module allocation::module grade ; 1 ) ; GetNthRecord ( module allocation::module grade ; 2 ) ; GetNthRecord ( module allocation::module grade ; 3 ) )

But the average came out wrong and I have not the foggiest why. For 1.0, 1.2, 1.4, 2.0 it came out as 1.0 although after discarding 2.0 as the worst grade it should have been 1.2.

  • Solution

Sorry, I should have remembered to mention there's a bug when using GetNthRecord() inside aggregate functions. Here's one way to work around it =

Average (
GetAsNumber ( GetNthRecord ( module allocation:::module grade ; 1 ) ) ;
GetAsNumber ( GetNthRecord ( module allocation:::module grade ; 2 ) ) ;
GetAsNumber ( GetNthRecord ( module allocation:::module grade ; 3 ) ) 
)

Or just do a simple =

( GetNthRecord ( module allocation::module grade ; 1 ) + GetNthRecord ( module allocation::module grade ; 2 ) + GetNthRecord ( module allocation::module grade ; 3 ) )  / 3

Also make sure that the calculation is unstored; Filemaker will not force this when using GetNthRecord().

  • Author

Hi comment,

 

What a weird bug. One would think that such a basic function/calculation would be properly implemented in FileMaker.

 

In any case, I tested it and it worked like a charm. Thanks a bunch.

 

Regards

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

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.