Template talk:Election results

Elections under multiple non-transferable vote
So I tried this out at Template:1946 Philippine Senate election results (sorry guys I know you wanted that to be deleted LOL) and there seems to be something missing for this type of election: I know there's a two-seat variant of this template but it doesn't work for 3+ winners in an election. Howard the Duck (talk) 21:21, 1 September 2021 (UTC)
 * 1) It doesn't show you who won. Let's imagine the reader knows nothing about this election. Okay, I suppose the candidate at the top won, but if this was a single-winner election, how come there are so many votes, with more votes than the people who voted?
 * 2) I suppose the percentages should be based on the turnout and not on the total votes, but I've seen similar elections use the total votes as the dividend.
 * 3) For these types of elections, the top x candidates win, so having a "Rank" column is a good visual cue.
 * You can add background colours for rows – see e.g. 1990 Slovenian presidential election, and you can manually add bolding to candidate and party names.
 * There may be a way to refactor percentages for candidate elections where people can vote for more than one, but what would the total figure for use of calculation be – would it be total votes cast for candidates or total number of voters casting valid votes (some voters may not use all their votes)? The total as it appears at the bottom would still be the total of votes cast for candidates, but I don't think this is an issue if you've got the valid votes line – there are many countries where the vote totals for parties are far larger than the electorate as voters have multiple votes (e.g. this or this). Not sure about adding a ranking column – potentially quite a bit of extra coding.
 * Ultimately it won't be possible or worth it to adjust the template for every possible layout – while going through different countries to convert to this template, I've formatted some using wikitables because only a tiny number of tables would look like that and it's not worth the extra coding. Cheers, Number   5  7  21:41, 1 September 2021 (UTC)
 * Background colors: I know you guys are talking about changing up the party color templates, but that Slovenian example has the same exact similar color to Template:Nacionalista Party/meta/color (LOL), and I've been trying to change that but the last time I did that, someone reverted because "We're using it here everywhere".
 * Also, I tried these out, and it doesn't work unless you change  to , but that got rid of the party column. Howard the Duck (talk) 22:04, 1 September 2021 (UTC)
 * It depends per election authority. I checked out Manx elections, which used an identical format, and they divided by total number of votes cast (therefore the current setup should give out the same results). On Philippine elections interestingly, these are normally not presented with percentages. I suppose there can be a way to turn off this feature? Here at Wikipedia, Philippine Senate elections have always been presented with percentages, but are never presented that way elsewhere. I'm actually interested on how election authorities do this. Howard the Duck (talk) 21:55, 1 September 2021 (UTC)
 * The row background colour is your choice; it isn't hardcoded to be that shade of green, I've just input that because that's what was used on the previous wikitable version. But good point re it only working on rows – that can be fixed. The percentage column could be hidden; I'll have a look at how much code that would take if you want. Number   5  7  22:23, 1 September 2021 (UTC)
 * Yeah, I was more gunning on a yellow color, as that what is being used. Just keep us updated once this is fixed up. Howard the Duck (talk) 22:32, 1 September 2021 (UTC)
 * Related question: For "partyx", is it supposed to be the full name of the party, the short name, or wherever the article name is at (except for disambiguation). Howard the Duck (talk) 21:59, 1 September 2021 (UTC)
 * You can pipe in whatever name you like; the meta color is called using the link, so as long as that is correct, how you pipe it is irrelevant (Zimbabwe African National Union – Ndonga and ZANU–Ndonga both call the meta color). However, if you're not linking, then you need the full party name to get the meta color to work. Number   5  7  22:23, 1 September 2021 (UTC)
 * Is there like a rule, or is it totally upon the discretion of anybody who's editing? If we're using US parties, is it recommended to be as "Democratic" or "Democratic Party" (or even "D")? Howard the Duck (talk) 22:32, 1 September 2021 (UTC)
 * There isn't a rule as far as I'm aware. There may be consensus for individual countries in their respective politics projects. Personally I would always go for the full name of the party unless it's significantly longer than the others and distorts the table. 'Democratic' is fine for an infobox summary, but I don't think is appropriate in a table.
 * Separately I've fixed the background colour for rows using 'cand1' etc. Will try and do the hiding percentages thing soon. Number   5  7  13:40, 11 September 2021 (UTC)

The functionality to refactor percentages for elections where voters can cast multiple ballots has now been added. If you use the 'divisor' function, it will refactor the percentage column into a % of valid votes cast (rather than total votes cast for all candidates). See an example at 1866 Surinamese general election. Cheers, Number   5  7  21:50, 6 February 2024 (UTC)


 * Thanks. Can we add an optional "#" leftmost column? In MNTV elections, the percentages or vote totals don't really matter, but on how you ranked in the tally. Howard the Duck (talk) 22:02, 6 February 2024 (UTC)
 * I'd suppose there can also be an option to remove percentage column entirely. Howard the Duck (talk) 23:15, 6 February 2024 (UTC)
 * Just to clarify, would the rank column be before the party colour one like this? It somehow seems a bit disjointed. Also, given tables are already ranked in order of votes received, what would be the purpose of the rank column?
 * {| class=wikitable style=text-align:right

!# !colspan=2|Candidate !Party !Votes !%
 * 1||bgcolor=| ||align=left|Bill Jones||align=left|Conservative Party||13,000||51.00
 * 2||bgcolor=| ||align=left|Eric Smith||align=left|Independent||12,000||49.00
 * }
 * 2||bgcolor=| ||align=left|Eric Smith||align=left|Independent||12,000||49.00
 * }


 * Separately, removing the percentage column would potentially require quite a lot of code to be added to hide the columns in multiple parts of the table (as currently the % column automatically appears if the votes column is used). However, you can effectively do the same thing already by hacking the template slightly, as below. Number   5  7  16:26, 7 February 2024 (UTC)
 * Yeah, I thought about the color column and the rank column and yes, it does look disjointed. However, I'd be ok with this if only we'd only show the rank column on multiple winner elections like MNTV and SNTV. I've peeked at WP:FLs, and the colour column, if there's a rank column, is quite far away from it; one colors the "#" column with the party color, but I won't recommend this. One more way is to put the color and the party columns together, but I've seen several election results tables that indeed show the color as the leftmost column (then again, those are single-winner elections), so people may be used to it, and expect it to be within that area of the results table.
 * Re: The purpose -- for MNTV and SNTV, the winners are for the top X positions; the rank column allows the reader to visually know who among the top X are; in jurisdictions where this type of election is being used, the specific value of X has become somewhat drilled into brains of voters, like "I need X names for this position".
 * One another way is boldfacing entire rows in results tables, like the old election tables, but it doesn't give you at first glance how many seats are contested in this "district". In cases such as 2023 Amber Valley Borough Council election, this is rather easy, as the winners are the top 2-3. In cases such as 2022 Calamba City Council elections, it's not readily apparent (I think it's 12, and I wasted 10 seconds of life counting it). Howard the Duck (talk) 22:12, 7 February 2024 (UTC)
 * Re hack: This hack removes the party column, which is pretty essential. If hiding the % is too hard to do, I'd be ok with keeping it. Howard the Duck (talk) 22:12, 7 February 2024 (UTC)
 * The hack doesn't get rid of the party column – I just didn't include it in the example – now added in to demonstrate it works.
 * It is also possible to add background colour to rows (like in 2004 Norfolk Island legislative election) to demonstrate who was elected (which I think is much clearer way of demonstrating who was successful than bolding). But I will have a go at adding a # column in the near future. Cheers, Number   5  7  22:20, 7 February 2024 (UTC)
 * i'd prefer bolding or even a checkmark than coloring an entire row (considering I've done that before lol) as we already color a cell for the party. This isn't like sports tables where we don't color an entire column.
 * I like how the hack looks like now tho. Let me know how you want this done (by numbers, bolding or coloring then let's see how it works in actual usage. Howard the Duck (talk) 00:13, 8 February 2024 (UTC)
 * It's in the code below. I used the seats function for the votes (and changed the title of the column using the |seatstitle parameter). Cheers, Number   5  7  23:00, 8 February 2024 (UTC)
 * Is there a way to have the winners be made to stand out other than manually boldfacing every entry? Howard the Duck (talk) 22:52, 10 February 2024 (UTC)

Adding # (ranks)
This would be hanby for multiple winner elections. I just dunno how it should be done as the color column is at the leftmost corner. Just make it optional, as the default should be the unnumbered version. Howard the Duck (talk) 13:19, 6 January 2024 (UTC)

Alliance
Hello, I was wondering if some change could be done to make the table less bulky when there's alliance. Currently, the tables look like this :

Don't you think the tables would look better like this ?

I feel like this would be even more needed when in many countries, alliances often have quite long names, like the french New Ecological and Social People's Union. But I aknowledge that I wouldn't know how to implement this change even if it get approved here. Cordially. Aréat (talk) 01:50, 8 March 2024 (UTC)
 * These tables aren't that wide, so I don't really see the need to remove an entire column. It's also somewhat confusing with the two bars of colour, especially if you're not reading a "here's what I changed" description right before. Also slightly concerned about how clear this is for screen readers.
 * On the other hand, backend code wouldn't be too difficult to rearrange. Primefac (talk) 15:51, 8 March 2024 (UTC)
 * In the second version, I don't think the arrangement of alliances is clear enough. The double column of colours is quite confusing, and only at the bottom do you find out that there is a total (and it's still not clear there that this is an alliance). Number   5  7  15:57, 8 March 2024 (UTC)

STV elections example
Hi, I'm happy to help with the coding (I know Julia, which is pretty similar to Lua), but I'm not familiar with this template or how it works.

Could the template be modified to handle STV elections? I think Template:STV Election box begin &co were used for this a few times, but they're a mess (everything strewn around 4 or 5 different templates and with none of the features of the election box template).

An STV template would need to:


 * 1) Allow for >2 rounds,
 * 2) Keep the total number of votes fixed across rounds (because the total number of ballots doesn't change),
 * 3) Indicate eliminations (e.g. with a red X mark),
 * 4) Indicate transfers (i.e. the change in each candidate's vote total from round-to-round).

Closed Limelike Curves (talk) 20:29, 20 March 2024 (UTC)
 * I don't think so as adding additional rounds requires a large amount of additional code and STV elections can go on for well over ten rounds. It would likely be easier to create a separate module that mirrors the style of this one, but only has the code for multiple vote rounds and doesn't have to factor in multiple combinations of seats/alliances/DSV etc. Number   5  7  20:53, 20 March 2024 (UTC)
 * Makes sense, thanks! Closed Limelike Curves (talk) 00:39, 21 March 2024 (UTC)
 * Oh, hmm, wait; it looks like it can already handle 3 rounds, so isn't it possible to just extend whatever loop generates the second/3rd/etc. rounds?
 * I'm interested in smaller elections (>10 round elections shouldn't really be displayed in a table like this, which will just get cluttered or confusing). I'm really just looking for something that can handle maybe 5 or 6 rounds. Closed Limelike Curves (talk) 15:48, 21 March 2024 (UTC)
 * It doesn't work on a loop basis. Every round has to have its own coding, and it's not just for the candidate rows, but also the headings, total votes, invalid votes, blank votes, electorate etc. Also, what you're proposing would require the existing round rows to be modified, which would add even more code.
 * If you're going to have a results template that works for STV, it should be done properly and be able to cover all sizes of STV elections, not just ones that one particular editor is interested in. Number   5  7  18:06, 21 March 2024 (UTC)

I also think a separate template would be better. I don't know how to do the template code, but I did some manual code tables for such election on the french speaking wiki, for example here and here, if it may help. One particularity that shouldn't be forgotten is the existence of the cumulative exhausted votes, starting with the second "round". Cordially. --Aréat (talk) 09:48, 4 May 2024 (UTC)
 * I've started developing Election results-STV. See how it works here - there are options to include or exclude percentages. There is one last thing I need to fix (the 'Total' row not appearing properly on the version without party names), otherwise I think it is nearly ready to go (the other thing I have not decided on is whether to include gridlines on exhausted rows. Comments welcome of course! Number   5  7  13:44, 4 May 2024 (UTC)
 * Oh, that's awesome, I didn't knew a template was already done this far. Well done! If you wan't feedback, I find it clearer to understand the results when the rows of eliminated candidates just end and then are empty on their right side while the rows of the candidates still "in" continue to be filled. But that's just my two cents. More importantly, from your example, it seem to me the fist count column should have the exchausted row filled with a "–" on both Votes and % subcolumns, not just %, so that it doesn't feel like the data is missing (by definition there can't be exhausted ballots in the first count). And I'm a bit wary of your decision to show percentages with the exhausted. It really should have a "–" as well. As far as I know, exhausted votes are never part of the percentage calculation for the remaining candidates. They're out of the count. That's why on my manual tables I even placed them under the total of remaining votes. (They're still included in the total of valid votes anyways). Finally, if you keep it above, I believe you will have to make the exhausted votes row be cumulative and indicate it as such, otherwise the total won't hold. Cordially.--Aréat (talk) 23:30, 4 May 2024 (UTC)
 * I hadn't done any special code for the exhausted row as I am not sure how it is normally shown. In the testcase I just created a normal row with the name 'Exhausted'. I'm open to ideas about how it could work, or whether it's even needed. Number   5  7  01:12, 5 May 2024 (UTC)
 * Wow, that looks amazing @Number 57! Thank you so much for all your hard work on this :)
 * From what I can tell, exhausted ballots are typically included in English Wikipedia infoboxes and IRV election results. Examples include 2009 Burlington mayoral election (disclosure: I made this one) along with 2018 Irish presidential election (I didn't make that one, and the rule is applied consistently across Irish elections).
 * Exhausted ballots are typically "out of the count" in that they can't affect the results anymore, but still meaningful in that they usually indicate "dissatisfied voters" (ones who are unhappy with all remaining candidates).–Maximum Limelihood Estimator 02:44, 5 May 2024 (UTC)
 * I'm a bit confused about what you say, as there were no exhausted ballots in the 2018 Irish presidential election as Higgins won on the first count, while for 2011 Irish presidential election (in which there were), they are not listed. From the STV election articles I've seen, exhausted ballots are not generally included. Number   5  7  02:55, 5 May 2024 (UTC)
 * I don't doubt many STV pages don't have exhausted votes, the same way many STV pages don't even have the different counts, only the first and last ones. Compare the table in the Huon consistency on the 2022 Tasmanian Legislative Council periodic election and its page on the french wiki. That's why a proper table is needed, to make it easy to actually add all the right info. Another example showing exhausted row done right, in my opinion, would be 2018 Guernsey electoral system referendum. The amount of such votes show why the percentage isn't included toward the percentages of the actual options. Cordially. --Aréat (talk) 11:00, 5 May 2024 (UTC)
 * In the context of Australian elections, ballots can't become exhausted during the count, because Australia requires full rankings (so the number of exhausted ballots is 0).
 * The main issue with excluding exhausted ballots from the percentages is that, depending on context and rules for counting, exhausted ballots can affect the results. This is especially true in STV elections (where they can affect the quota), and is also true of voting systems other than IRV. –Maximum Limelihood Estimator 16:12, 5 May 2024 (UTC)
 * Sorry, I meant the 2011 one!
 * WRT the 2011 election, I was referring to the infobox. –Maximum Limelihood Estimator 14:38, 5 May 2024 (UTC)
 * Exhausted votes definitely exist in Australia. In the example used above, Tasmania, many elections have exhausted votes, for example here in 2018. Not all states require full ranking. New South Wales, for example, doesn't require it for its legislative council. The election of 21 of its members only require voters to mark up to 15 candidates, . Anyways, it's important to have a row. I go back on my previous statement, though, as there do seem to be some place like Ireland where indeed they're included in the count. In 2011, a candidate had to gain half of 1,771,762 valid votes, so 885,882. A candidate could thus have 50 % of the remaining non exhausted votes and not be elected until getting that number in a further round. So, the template should simply allow for exhausted votes to be included in the percentages, or not be included. It all depend on the voting system, which varies. Cordially.--Aréat (talk) 19:18, 5 May 2024 (UTC)
 * Manually, the table for the irish 2011 election look like this, for example.--Aréat (talk) 19:40, 5 May 2024 (UTC)
 * Ooh, I really like this. Thanks! :) –Maximum Limelihood Estimator 19:55, 5 May 2024 (UTC)
 * Do you happen to have time to test Number57 template above on the irish election results to see how it compare? :] --Aréat (talk) 14:41, 10 May 2024 (UTC)
 * Apologies, I will try and sort it this weekend. Just moved house and well behind on my watchlist! Number   5  7  22:59, 10 May 2024 (UTC)
 * I was asking Maximum! Since he seemed very enthusiasmed by it. You already did a great job as far as I can see. No problem, take your time. --Aréat (talk) 12:14, 11 May 2024 (UTC)

Add notes in the "votes" column
I am currently editing the 1989 Polish parliamentary election article, and the results table has three different columns - one for the constituency seats reserved for independent candidates (which included Solidarity's candidates, since it had no direct nomination rights), one for the constituency seats reserved for PZPR and its satellite parties, and one for the national list (which was reserved entirely for the PZPR bloc). I would like to add a "did not contest" note in italics where the votes column would otherwise go, but the template replaces every text string with 0. Is there a way to add those notes? Glide08 (talk) 22:47, 14 May 2024 (UTC)

I'm editing the same article. In the end we want to make it look something like this: ImperatorPublius (talk) 23:16, 14 May 2024 (UTC)

Add a fourth round
I was fiddling with the Template in the sandbox, attempting to recreate the results of the 2022 Italian general election results wikitable, but I noticed that there's no option to add a fourth round like the one seen in the table below. I think it would be worthwhile to have that option for elections like the Italian ones where there are more than 3 sources of votes/seats that are independent from each other.
 * TBH I think the table below should not be separated into four – the Aosta Valley is a first-past-the-post constituency and should be included in the FPTP column. Number   5  7  21:33, 18 June 2024 (UTC)

Percentages
The template shows the percentages without counting blank votes. This in turn shows wrong results AlexBobCharles (talk) 08:48, 12 July 2024 (UTC)
 * Blank votes can be added in cases where they are considered valid votes (such as in Colombian presidential elections). See, for example, here. However, this should only be done when blank votes are deemed to be valid votes (i.e. NOTA). Cheers, Number   5  7  21:57, 12 July 2024 (UTC)

Night mode: overall statistics barely visible
Labels of overall statistics are barely visible. This applies to things like the labels of "Valid votes", "Invalid votes", "Blank votes". These labels are set with "background: inherit". The night mode extension applies an #202122 text color of anything with an background color, in the belief that the background color is different than black. In this case though, the background is dark, so the text is barely visible. Snævar (talk) 18:20, 15 July 2024 (UTC)

Can you guys make election results template for Serbian Wikipedia?
I'll help into making it for Serbian Wikipedia. “Template:Election results” will be “Шаблон:Изборни резултати” (Infobox will be Инфокутија). Votes are “Гласови”, Seats are “Мандати” etc. Hadjnix (talk) 09:05, 19 July 2024 (UTC)