PivotTable
, which is currently blank, and StarryCompare
, which is currently zeros (because PivotTable
PivotTableFlipped
. Google Sheets is not able to make Pivot Tables that have too many columns, and there are far too many vote-ids for Google to work with. Therefore, we have flipped the rows and columns to make PivotTableFlipped
.
PivotTable
sheet, use TRANSPOSE
to recreate the Pivot Table that we made in Activity 1-2. Check to make sure that none of the cells are colored red (i.e. none of them are blank).
StarryCompare
. The table should have been repopulated -- i.e. the calculations should be back in the sheet, now that PivotTable
has data.
GeneralCompareTemplate
. Right click on the tab and rename it GeneralCompare
.PivotTable
(like =PivotTable!A5
) to fill the row and column headers (cells G10:G79
and cells H9:JG9
, starting in the blue boxes). Your spreadsheet should now look something like this (click to see it bigger): Data Validation
to allow a list of names in cell B2
. These names can be referenced from the column A
in PivotTable.B3
, use the MATCH
function to get the legislator's alphabetic rank. Reference cells from Column A
in PivotTable
. The first (in PivotTable!A2
) should be 何俊仁 Albert HO and the last person (in PivotTable!A71
) should be 黃碧雲 Dr Helena WONG (Legco is horribly inconsistent about the formatting of our legislators' English names -- sometimes they put the surname first, sometimes last -- which is why we are using both English and Chinese names.) B7
, use the OFFSET
function to re-display the name of the legislator in cell B3
). You should offset a cell from the PivotTable sheet (which should be sorted alphabetically). The number of rows to offset should be based on the alphabetic rank we just computed (in cell B3
).H7:JG7
(the green cells), modify the function in B7
to display the votes of the legislator whose name appears in B2
and B7
. How many rows should you offset? How many columns? You will need to use an absolute reference ($
) to make sure you always use cell B3
.
StarryCompare!B2
to cell H10
and modify it. Remember that the name of the legislator that we want to compare to is B7
on this sheet, and his/her votes are in H7:JG7
. (You will also need to use an absolute reference somewhere.)
COUNTIF
function to again compute num_agree
,num_disagree
,and num_not_voting
in columns C:E
(the orange cells).
F
, compute the score
of each legislator into that column using this forumla:$$\frac{\text{num_agree}-\text{num_disagree}}{\text{num_agree}+\text{num_disagree}}$$
B
, use the rank()
function to calculate the rank of each legislator, given the current comparison function.rank()
function gives an error because one of the legislators gives a "divide by zero" error. Therefore, we will need to override his score so that we can rank the others. The IFERROR()
function checks if a cell contains a valid number. Modify the score function in column F
to set the score to some default value (use -100) if a division by zero occurs.B9
, and click on View -> Freeze -> Up to current row(9)
. This should freeze the first 9 rows. Now we can sort by Column B
.B2
to pick a few other legislators and rank the rest against them. Then sort the table by rankings. Make sure that things work. ElectionData
and Translations
. In A10
, write a formula using LEFT
, MATCH
(you will probably have to use MATCH
with 0 because the ElectionTable is unsorted) and OFFSET
that will pull out the party (政治聯繫) for each legislator from ElectionTable
. This should be quite straightforward:
EnglishTranslations
sheet, and you can use a similar MATCH
and OFFSET
to translate the Chinese to English if you wish.)
We now have a nice spreadsheet that is also an application -- i.e. other people can use it to make their own conclusions about the data. Before we go on, a few things to keep in mind:
D10
. But doing it step-by-step is a good idea because (1) it breaks the large problem into manageable pieces and (2) it will be easier to figure out what we did later.