Election nights are always fun. They last a long time (longer, indeed, than you think time can last). The candidates are always looking for their piles. The agents with the clipboards are ensuring democracy is done right on their candidate alone. You, meanwhile, are just tired that you’ve been waiting around all night, and there is another recount.
And that’s just if you’re at the count. At the office, you you’ll need coffee to stay awake, so maths is the least of your worries. So help inputting results wouldn’t go amiss.
I (hopefully) have created a bulletproof way of inputting results for the Daily Post, with a little help from my friends. They gave me a few pointers with formulas. I did the rest.
North Wales has five counties up for election. 243 wards. Over 700 people being elected. That’s a lot of numbers. So, how do we input them?
First, I split all the counties up. Five Google Doc spreadsheets. This way, it doesn’t get too confusing. All the wards are in columns, with a space next to it to input the result. Scroll across, input result. Easy.
Then, we need to know who won. So, seeing as the most votes wins, you pull the result down to another cell. Not easy, when numbers are all over the place. So, I needed a formula. With a bit of help from @PaulBradshaw, a Vlookup formula would work. It would pull the top candidate down. Great, for most of them. It, however, would require the results to be inputted on the left.
So, @aendrew pointed me towards an idea that looks amazing. I decided to use a =large formula to rate the candidates. =large(c2:c12,1) would pull the largest number (for example) from that range down to the specified cell where the formula was entered. Great. You can add a 2, 3, or anything up to however many numbers there. You want the 50th in a series of 100? Just select the range, and type 50 at the end.


Now, we need a name. In this case, =index(B2:B12,match(B15,C2:C12, 0)). This would take the value in cell B15 – where the largest number is – and match it with the number in cells C2 to C12, where the results were inputted. It will find the exact match, and then look across at the cell next to it, in B2 to B12, and bring the candidate name down to cell B14, where the formula was entered.
Now, we have the candidate name on one cell, and the total winning votes on the cell directly below. Repeat that if two or three, or four, councillors are being elected. Easily done.
But, you can’t do anything with that data. Yes, you can’t. So, you need to flip it. Looking at that way is easier to input, which is the aim of this spreadsheet. Looking at it another way is easier to collate with other data sources. So, we need another formula.
=transpose(’1: ENTER RESULTS HERE’!A13:BX22)

This will take everything in the cell ranges A13:BX22 (where the results will be sorted and brought down to by the other formulas), move it to another sheet, and transpose them. That is, flip them around. You end up, that way, with columns of numbers that are easier to work with when making maps, and results. Nothing needs to doing to this, apart from selecting all the data, copying, and pasting as values only to the next sheet. Taking the formulas will ruin it, once you see what we’re going to do.
On the third sheet, we will sort the name column, where the ward names are, in A-Z format. Get rid of the spaces with the extra #num rows, and copy to the next workbook, called Conwy Results TO MERGE. So called, because you need a clean workbook to merge with Fusion Tables, which is exactly what this will do.
You put the data only into the workbook, which already has the county, in this case Conwy, repeated down the side many times, and the headings. These are uniform for a reason.
This table just needs the data copying to, then closing. Open Fusion Tables, make a new table from Google Spreadsheet, select the relevant TO MERGE sheet, and then merge that with the KML file of the county.
What we’re going to do is use these headings to write the info box code, so it works for 1 person elected or 4. The code is:
<div class=’googft-info-window’ style=’font-family: sans-serif’>
<font size=”+1″>This is <b>{Ward Name}</b> in <b>{County}</b></font><br>
Winning this ward was:<br>
<b>{Winner 1}</b> ({Votes 1})<br>
<b>{Winner 2}</b> ({Votes 2})<br>
<b>{Winner 3}</b> ({Votes 3})<br>
<b>{Winner 4}</b> ({Votes 4})<br>
This doesn’t leave any marks on it through typing commas. It works by using the cells as the text. If there’s nothing in the cells, nothing will appear in the info box. Clean, and at the same time, it makes nice prose on the top: This is “Ward Name” in “County” will read, for one ward at least: “This is Gogarth in Conwy.”
The map will then have all the details you need to see how the county voted on May 3rd.
I will update with the winning maps – suffice to say, this is the way to do work if you know you’re going to get data, but don’t know the figures. Easy to just drop it in, then spend 5 minutes copying, pasting, and merging. All the hard work has been done beforehand.