djlane Posted August 14, 2007 Posted August 14, 2007 Hi guys, I'm trying to make a simple system to calculate golf handicaps. The basic calculation is to take the best 10 scores from the last 20 scores of an individual. i would like to do this with relationships & calculations if possible, instead of using a script. I would have a table which holds the scores and a separate table which holds the players. How to find the last 20 games (scores) that a player played, and then how to select the 10 lowest scores from that list without using a script?
Vaughan Posted August 14, 2007 Posted August 14, 2007 Sort the relationship by "score" in ascending order. Easy.
David Jondreau Posted August 14, 2007 Posted August 14, 2007 Nothing's ever that easy. He wants the lowest 10 scores from the last 20 scores. What comes to mind is to sort the relationship by date descending and use a custom function to grab the 10 lowest.
sbg2 Posted August 14, 2007 Posted August 14, 2007 I think you're going to need a script somewhere. I would suggest using a script to enter any new score for a player (rather than allowing multiple scores to be input into a portal). Once a score is submitted a script would run to flag the last 20 scores and pick the lowest 10. Then sum the lowest scores, divide by number of scores used and multiply by .96. Also take into account the course rating (by tee box played) and slope rating. The lowest number of strokes does not always equate to the lowest "score". You should be using the differential not the actual strokes. (you can see an example in the attached image which shows a round where 87 strokes were played resulting in a lower "score" than from courses where less strokes were taken). see http://www.ehow.com/how_15107_calculate-golf-handicap.html for starters.
Vaughan Posted August 15, 2007 Posted August 15, 2007 "Nothing's ever that easy. He wants the lowest 10 scores from the last 20 scores." Sort the relationship by date descending. Use the List() function to pull out the scores (which will now be newest to oldest) and cut off the list after 20 values. Get this 20 value list then sort it by score ascending, truncate it at 10 values. This could all be done in a calculation field.
djlane Posted August 15, 2007 Author Posted August 15, 2007 Hi sbg2 - I'm trying to avoid using a script if I can. Yes, I understand about the course rating, differentials etc. Thanks Vaughan, I looked at the list() function but I don't see how to cut off the list after 20 values? Nor how to take the list of 20 and truncate it to 10? I too thought it was easy until i tried to do it !
David Jondreau Posted August 15, 2007 Posted August 15, 2007 Check out the LeftValues function, then a Custom Function at Brian Dunning's site that will sort a list for you and then LeftValues again.
Vaughan Posted August 15, 2007 Posted August 15, 2007 Yes, LeftValues() function and SortValues() Custom Function should do the trick. Note that the SortValues() CF uses the MinValue() and MaxValue() CFs as well, and you'll need FMP Advanced to add the CFs to your files.
djlane Posted August 16, 2007 Author Posted August 16, 2007 OK guys, I have decided to go with a script as I'm intimidated by Custom Functions ! Its now running well with a script. thanks
Recommended Posts
This topic is 6370 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now