Template talk:Winning percentage

Divide by zero error
If the wins and losses are both 0, then the template will return a divide by zero error. I addressed it somewhat at CBB Standings Entry. Maybe something like that could be done here. — X96lee15 (talk) 22:16, 3 December 2009 (UTC)
 * Thanks for pointing that out. I didn't even test that scenario. Should be fixed. I added this case to the examples in the documentation.—NMajdan &bull;talk 22:49, 3 December 2009 (UTC)

.000
Please explain to me why ".000" isn't technically correct.—NMajdan &bull;talk 03:42, 4 December 2009 (UTC)


 * The result of a divide by 0 is undefined (not .000). In my last edit though, I may have removed too much (which I think I've fixed but the WP servers seem to be lagging quite a bit) so that 0 win and 1 loss is reporting "dash" when that definitely should be ".000". I was just trying to fix the case of 0 wins and 0 losses. — X96lee15 (talk) 03:48, 4 December 2009 (UTC)


 * Ok, that I'm ok with. Zero games, fine, em dash will work. I definitely had an issue with 0 wins, more than 0 losses or ties. But, I see you changed that. Thanks.—NMajdan &bull;talk 03:51, 4 December 2009 (UTC)

4 or 5 decimals places
Can we add an optional parameter to display the percentage to 4 or 5 decimals places? That would help a great deal with breaking ties on a list like this: List of college football coaches with a .750 winning percentage. Thanks. Jweiss11 (talk) 10:51, 5 October 2010 (UTC)

division
Why does .660 render as .663? and not .654, which is 100/153 (totals wins/total games)? hello, i'm a member  |  talk to me!  22:38, 1 November 2010 (UTC)
 * Because 100 wins and 3 ties is computed as 101.5 wins (1/2 wins per tie). 101.5/153 == .663. — X96lee15 (talk) 02:59, 2 November 2010 (UTC)
 * Thanks. I'll put that in the documentation so others won't be as confused. hello, i'm a member  |  talk to me!  00:50, 7 November 2010 (UTC)

much later comment
Just discovered this template during a reviewing exercise. Note that the above computation is correct by current NFL rules. Prior to 1972, the NFL did not figure ties in at all. Thus, in 1967, the Colts and Rams each had a record of 11-1-2, which was calculated as .917 (i.e., 11/12), rather than as .857 (i.e., 12/14). So if you want to use this template, you need to make sure that (a) the league table you're calculating uses this approach, and (b) that you are calculating correctly for time in history you're discussing. StevenJ81 (talk) 19:39, 4 November 2013 (UTC)
 * Perhaps we add a  parameter that ignores ties when set to "y". Or something like that. — X96lee15 (talk) 21:03, 4 November 2013 (UTC)

Automatically create record
Is it possible to edit this so that instead of just the percentage, a flag could be added (by default, no, for backwards compatibility) so that the win-loss record would automatically proceed the percentage? For example, .660 would display  (i.e., include the win-loss-tie record, not just percentage). This feature would seem to prevent typos and generally make life easier when adding and updating records. If this template already exists, and I just don't know it, could you point me in that direction? Thanks! 70.208.147.170 (talk) 04:46, 13 October 2014 (UTC)

Parameter to specify precision
I would love to use this template for tennis records, but in articles like ATP World Tour records it is standard to use 2 decimals for precision instead of 3 (e.g., 66.67% instead of 66.667%). Is it possible to add that option to this template? Thanks a lot, Gap9551 (talk) 17:58, 21 November 2015 (UTC)

Explain formula
To clarify what X96lee15 says, the formula is: winning percentage = (wins + (ties ÷ 2)) ÷ (wins + losses + ties) Which gives (916 + (36 ÷ 2)) ÷ (916 + 329 + 36 ) = 0.729 and indeed &#123;&#123;Winning percentage|916|329|36&#125;&#125; = .720 I do not know how to get this formula into the "tool tip" or other comment place where it is obvious. I dug, and searched, and found X96lee15 comment on a different page, and then came here as the last place. Could someone who knows more than me, put this formula into the tool tip?

I am aware that it is a struggle to get the computer to handle the "edge" cases, i.e. when one or more of those numbers is zero. But I assume a reader knowledgeable enough to understand the formula, also is knowledgeable enough to understand zero. Nick Beeson (talk) 13:46, 2 January 2016 (UTC)

Tie error with no losses?
I was just over on List of NCAA Division I FBS football bowl records and I noticed that New Mexico State's 3-0-1 record comes out as 1.000 instead of .875 as would be expected. I confirmed that it wasn't a typo, that the tie was properly placed in the page. I think there might be an error where if wins > 0 and losses = 0, it automatically returns "1.000" before checking for ties. I want to see what happens in the strange case of a team with more ties than wins, but no losses.

&#123;&#123;Winning percentage|2|0|4&#125;&#125; = .660

...Yeah, that's what I thought. I'll see if I can fix this myself, but I'm not confident in my abilities. Cyberchao X (talk) 21:44, 10 January 2018 (UTC)

Okay, it looks like I fixed it myself after all. The problem was exactly what I thought--it was coded to automatically return "1.000" if wins were greater than 0 and losses were 0, with no reference to whether the parameter for ties was present. It should work properly now. Cyberchao X (talk) 22:16, 10 January 2018 (UTC)

Allow commas in wins/losses/ties?
Would it be possible to allow for commas in the wins/losses/ties parameters? The numbers are easier to read with commas once you get into the thousands, but using them in this template breaks the winning percentage calculation due to unexpected punctuation. It would be great if there was a way for the percentage calculation function to ignore commas if editors use them in the other parameters. Thanks! WildCowboy (talk) 05:02, 9 March 2018 (UTC)
 * Yes check.svg Done —Bagumba (talk) 11:52, 28 May 2020 (UTC)

Template-protected edit request on 25 June 2018
Add the "compute_ties=" parameter as mentioned here: Template talk:Winning percentage. Currently working on Overwatch League articles where I would like to use Winpct, however it isn't possible as ties aren't valued/wouldn't be considered half-wins. Ideally would need the ability to omit ties in a similar fashion to that mentioned in the talk page. Would be useful in any scenarios where ties aren't valued, but still needed in the total.

Solution also seems simple enough (parameter can be changed to ignore_ties or whatever seems suitable):

.000 to .000 Wiki nV (talk) 23:01, 25 June 2018 (UTC)
 * Red information icon with gradient background.svg Not done: please make your requested changes to the template's sandbox first; see WP:TESTCASES. &mdash; Martin (MSGJ · talk) 22:13, 28 June 2018 (UTC)
 * Hi Jason, I edited two versions in the sandbox. The first version adds the "omit_ties" parameter and maintains the same test case results the current template generates. The second version adds the "omit_ties" parameter and achieves all the desired test case results, I only realised they're user added after so I'm not sure if you still want the template to cater for those. Wiki nV (talk) 01:12, 30 June 2018 (UTC)
 * I've studied the code and still have no idea how it works. If you assure me you have fully tested the change and it works correctly then I will deploy. &mdash; Martin (MSGJ · talk) 07:09, 2 July 2018 (UTC)


 * Hi again, to hopefully keep everything as simple as possible I changed the sandbox template to only include the "ignore_ties" parameter addition as that's the functionality I wanted to add. Can confirm test case results output the same as the current live template.
 * Currently when ties are included the Winning percentage is calculated where ties count as a ½ win, i.e. $$\text{winning percentage} = {\text{wins}+0.5\cdot\text{ties}\over\text{wins + draws + losses}}\cdot100\%$$
 * What the "ignore_ties" parameter hopes to achieve is the calculation when ties hold zero value and the equation is simply: wins divided by the total number of matches played, i.e.
 * $$\text{winning percentage} = {\text{wins}\over\text{wins + draws + losses}}\cdot100\%$$
 * The only change now included is rewriting the (+ 0.5 * ties) part from +(/2) to
 * Which is a simple if statement, so if the "ignore_ties" parameter is included (=y) do nothing, else retain the current (+ 0.5 * ties).
 * Also, just a worth a note, the {{code| |{{#ifeq:{{{record}}}|y|) }} which you thought does nothing actually generates the closing bracket for when the "record" parameter is used e.g., {{code| 0–0–1 (.500) instead of 0–0–1 (.500 }}. It's also not my addition, it already exists in the live template.
 * Hope that covers everything. Cheerio. Wiki nV (talk) 11:01, 2 July 2018 (UTC)
 * Okay I have deployed. Thank you for trying to explain &mdash; Martin (MSGJ · talk) 11:13, 2 July 2018 (UTC)
 * Many thanks. By the way, when you get a moment, if you give Template:Winning percentage/doc a quick glance and check it's satisfactory I would appreciate it. Figured at least one other person should review it. Cheerio. Wiki nV (talk) 12:09, 2 July 2018 (UTC)

Template-protected edit request on 11 May 2019
Change template call ifempty to if empty to avoid the redirect. That template is transcluded in over 20,000 articles through being called in this template; that unnecessary redirect has to be followed every time one of those articles is viewed. Colonies Chris (talk) 16:07, 11 May 2019 (UTC) Colonies Chris (talk) 16:07, 11 May 2019 (UTC)
 * ✅ — xaosflux  Talk 19:38, 13 May 2019 (UTC)
 * Thanks, Colonies Chris (talk) 08:01, 14 May 2019 (UTC)

Template-protected edit request on 3 October 2022
Is it possible to make the template display percentages with the % symbol instead of with a zero value 0.XY and that it would also display  as 0–0 instead of —? Qwerty284651 (talk) 23:30, 3 October 2022 (UTC)
 * Red information icon with gradient background.svg Not done for now: please establish a consensus for this alteration before using the template. It is probably possible, but not reasonable. The template has behaved this way since 2009 (see talk sections above). 0/0 does not result in a percentage of 0%. Displaying "–" or "n/a" or something similar is appropriate.  – Jonesey95 (talk) 22:42, 4 October 2022 (UTC)
 * So be it. Qwerty284651 (talk) 22:50, 4 October 2022 (UTC)
 * One or more of the features you desire may be present in Percentage. – Jonesey95 (talk) 22:51, 4 October 2022 (UTC)
 * Won't cut it. Till next time. Qwerty284651 (talk) 23:29, 4 October 2022 (UTC)

Edit request 3 June 2024
No change. Asking for guidance. How can I set the 1.000 to display as 1.00, i.e. limit it to 2 decimals? Is there a decimal customization param for that? Qwerty284651 (talk) 02:33, 3 June 2024 (UTC)


 * According to the /doc page, "The result is displayed as a decimal point followed by three digits, as is standard in sports standings." So no, I don't see a param that would be able to alter from 3 to 2 decimal places. So sorry, editor . And I would ask you to please only use TPER when you actually want to edit a subject page. If you want to seek editing help, then please use the Help or Admin help template. Thank you for your help with this!  P.I. Ellsworth &thinsp;, ed.  put'er there 09:17, 3 June 2024 (UTC)