Converting a #N/A error to a value: =ISNA

I had one dataset which I wanted to convert to a timeline. But the dataset did not include all dates - only those on which a particular event occurred. 

So I had to fill in all the dates that were missing. That was pretty easy: type the first two, then select them and drag the + at the bottom right as far down as I needed (you can also double-click on it to copy it down to the last neighbouring value).

And I had to copy across all the values that matched the dates, which I did using the =VLOOKUP formula, also copied to the end.

But where there was no value to match, the VLOOKUP formula returned #N/A - and I needed it to say 0.

So I used =ISNA

=ISNA is a very simple formula: it checks if another cell is #N/A (IsNA - geddit?). If it is, it fills the cell containing the formula with TRUE. If it's not #N/A, it says FALSE. 

Example: A2 says #N/A. If you type the formula =ISNA(A2) into cell A3 (or any other cell), and press enter, it will change to TRUE. If you then type a number or text into A2, then A3 will change to FALSE.

So far, so abstract. But why was this useful to me? Because I needed to convert all my #N/As into the number 0.

So, in column A I had dates, and in column B I had the number of events on that date - or #N/A where there were none. In cell C2, here's the formula I typed: 

=ISNA(B2)

And copied down the entire column, so cell C3 said =ISNA(B3), and so on. Now I had a column full of cells that either said TRUE or FALSE.

Now I used an =IF formula to convert those to numbers.

In cell D2 I typed the following:

=IF(C2=TRUE, 0,B2)

Which did this: if cell C2 said TRUE (which meant that B2 said #N/A), then fill this cell with 0. If not, then fill it with the value in B2.

Once copied down the column, this now meant I had a column identical to column B, but with zeroes instead of #N/A.

There is probably a formula that would do both in one column, but there you go. ISNA explained.

PS: there are a whole series of =IS tests for other errors or types of content, including =ISERR for any error except for #N/A.

Looking up someone's voting record: VLOOKUP

Here's a formula which may be useful if you need to find information associated with something or somebody - for example their voting record or year of establishment. It's called VLOOKUP and goes like this:

=VLOOKUP(what you're looking for, what part of the spreadsheet contains both that and the related information that you want, which number column has the information you want, how strict you want to be about matches)

That's pretty wordy - here's a concrete example broken down (let's assume this is typed in cell D2):

=VLOOKUP(C2, A2:B300, 2, Exact)

In C2, then is the value we're looking for - let's say it's 'David Cameron'
David Cameron is somewhere in column A; his vote is next to his name, somewhere in column B.  
The information we want to get back is in column B, which is the 2nd column in our range, so we call it '2'.
We want an exact match, rather than the closest match, so we add 'Exact' at the end.

You can obviously change the contents of C2 to change what's being looked up.

Some things to watch:
This will return the first result, so order data accordingly. 

For journalists this is most likely to be useful as part of a larger calculation - otherwise you'd just use Find.