# I'm trying to create a golf app for my friends to track our scores over the golf season both Gross and Stableford points (per hole)

**URL:** <https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983>\
**Category:** Ask for Help\
**Created:** [May 1, 2024, 3:13pm UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983 "2024-05-01T15:13:52Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MikeMacmarts](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MikeMacmarts](https://community.glideapps.com/u/MikeMacmarts)\
**Post date:** [May 1, 2024, 3:13pm UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983/1 "2024-05-01T15:13:52Z")

</div>

The problem I have is that I have created a table with the hole indexes (1 to 18) and on the User Table I have a master score for both Gross and Nett (Stableford) score (1 to 18 twice). So the player enters the score per hole on a History Table (for each Major 10 competitions in the club) I then check using Actions if the score entered is less than the previous score entered for that hole. If it is I update the score on the User table (I check to ensure its not zero first). Also on the user table I need to perform a calculation each time the User enters a new lower score to calculate the Stableford points for that hole, for the users handicap (stored on the User Table also). I’m struggling on how to perform the calculate to create the stableford score per hole for each user. The calcuation is as follows If Hole 1 is Index 6 and the User has a handicap of 6 or more he has a shot on the hole. If the score entered is Par for the hole (4) Then the user gets 2 points Plus an additional 1 point since he has an extra shot. Total Stableford points for the hole is 3.

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [May 1, 2024, 4:20pm UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983/2 "2024-05-01T16:20:39Z")

</div>

You could use two JavaScript columns, the first one to calculate the number of strokes received on the hole, and the second one to calculate the stableford score.

To calculate strokes received:

```auto
let index = p1;
let handicap = p2;
let strokes = 0;
while (handicap > 0) {
  if (handicap >= index) {
    strokes++;
  }
  handicap -= 18;
}
return strokes;

```

- `p1` is the Hole Index
- `p2` is the players handicap

And to calculate the stableford score:

```auto
let par = p1;
let strokes = Number(p2);
let gross = p3;
let nett = gross - strokes - par;
let points = 
  nett >= 2 ? 0 :
  nett === 1 ? 1 :
  nett === 0 ? 2 :
  nett === -1 ? 3 :
  nett === -2 ? 4 :
  nett === -3 ? 5 :
  nett === -4 ? 6 : '';
return points;

```

- `p1` is the Hole Par
- `p2` is the strokes received (previous column)
- `p3` is the players gross score for the hole

Here is how that might look in the data editor:

 ![CleanShot 2024-05-02 at 00.17.36@2x](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/8/18e62551d99b59d544347b05928882c805c89d9b.png)

oh, I should point out that the first of the above only works for zero or positive handicaps. If you have any players lower than scratch, then it would need adjusting.

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [May 2, 2024, 12:24am UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983/3 "2024-05-02T00:24:31Z")

</div>

I see a thread about Golf, I know for sure you have already responded.

---

<div class="post-metadata">

**Author:** ![MikeMacmarts](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MikeMacmarts](https://community.glideapps.com/u/MikeMacmarts)\
**Post date:** [May 2, 2024, 11:19am UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983/4 "2024-05-02T11:19:10Z")

</div>

Thanks Darren looking forward to working on this over the w/e.

---

<div class="post-metadata">

**Author:** ![MikeMacmarts](https://avatars.discourse-cdn.com/v4/letter/m/a4c791/32.png) [@MikeMacmarts](https://community.glideapps.com/u/MikeMacmarts)\
**Post date:** [May 2, 2024, 5:26pm UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983/5 "2024-05-02T17:26:15Z")

</div>

> [@Darren\_Murphy](#):
>
> ```auto
> let index = p1;
> let handicap = p2;
> let strokes = 0;
> while (handicap > 0) {
> if (handicap >= index) {
> strokes++;
> }
> handicap -= 18;
> }
> return strokes;
> 
> ```

Works a treat Darren - Thanks a bunch

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [May 9, 2024, 5:26pm UTC](https://community.glideapps.com/t/im-trying-to-create-a-golf-app-for-my-friends-to-track-our-scores-over-the-golf-season-both-gross-and-stableford-points-per-hole/72983/6 "2024-05-09T17:26:42Z")

</div>

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.
