Sometimes, things aren’t what they seem. Like false advertising, optical illusions and hidden agendas, on occasion numbers in Excel may appear “fraudulent”. And that can cause issues for spreadsheets, whether you are using them for data manipulation / reporting, forecasting, budgeting or modelling.
In this instance, cell E5 has been modified. It has been stored as text, even though it looks like the number three [3]. This can happen in real life when you extract data from third party management information systems and they have been stored as an incorrect data type, e.g. text. SUM treats this number here as having zero value whereas the more convoluted addition carries on regardless because the mathematical operator ‘+’ coerces the number into behaving like a numerical value. Multiplying by one [1] would have the same effect.
SUM, SUMIF, SUMIFS and PivotTables all treat numbers stored as text as zero in mathematical aggregations. We need to clean the data so that the data that appears to be numerical is indeed numerical.
You might think you can spot the issue in such a small dataset, but what about the one below?
Is that summation right? How are you going to check?
It turns out that there is a simple way to check using the COUNT function. COUNT counts the number of numbers in a range, so we can use it to spot numbers that aren’t numbers:
Here, the formula in column I highlights when a number is not a number. Note how it reports by exception: if the cell in question contains a number then COUNT(Cell_Reference) equals 1 and
=1-COUNT(Cell_Reference)
equals zero. Only non-numbers will be highlighted – it’s better to know I have two errors rather than, say, 14,367 values working correctly.
You could use conditional formatting instead:
Then, I have selected ‘Use a formula to determine which cells to format’ and then typed the formula
=NOT(ISNUMBER(E3))
This calculation works on the range (ensure the cell is E3 not $E$3) in that you specify the cell in the top left-hand corner of the range selected (here, cell E3). The function ISNUMBER is TRUE if cell E3 contains a number and FALSE otherwise. NOT then simply applies the logical opposite. Hence, any “fraudulent numbers” will be TRUE and the conditional formatting will be applied.
Great. So now fraudulent numbers are identified, how do you fix them?
The easiest way is perhaps a little non-obvious (new word I have just made up) if you have not seen this trick before. You use ‘Text to Columns’!
For those not familiar with this age-old feature in Excel, ‘Text to Columns’ is found on the Data tab of the Ribbon and splits text in a single string into one or more columns based upon the occurrence of a special character (known as a delimiter). Comma separated value (CSV) are one such example, whereby strings are split each time a comma “,” appears.
We don’t care about splitting the text, but we shall still use this feature. Let’s select the cells E3:E7 and then apply ‘Text to Columns’ (click on the button in the Data tab or use the shortcut ALT + A + E). The following dialog will appear:
Nice trick, eh? Sometimes, for reasons I have never quite fathomed, this method fails. If you are unlucky and this happens to you, there are two fallback options.
The first is a simple trick with ‘Copy’ and ‘Paste Special…’. As mentioned earlier, multiplying text that looks like a number by the numerical value of one [1] will convert – coerce – this number into its displayed value. Therefore, If I type the number one [1] into cell A1 (say) and then copy this value / cell (CTRL + C):
If you forgot to select cell E2, here is your reprieve because you may check / uncheck the ‘My table has headers’ checkbox accordingly!
The Power Query Editor will then load, and you should note that as part of the upload, ‘Changed Type’ has automatically been applied in the ‘APPLIED STEPS’ pane and you can see here that the Data Type ‘Whole Number’ has been adopted:
The issue with this approach is that makes a copy of the table elsewhere in the workbook and does not transform the original values (which may or may not be what you want). Nonetheless, fraudulent numbers begone!
Word to the Wise
I strongly recommend that you apply the transformations in the order documented above. ‘Text to Columns’ takes seconds to implement and usually works. When it doesn’t, ‘Copy’ and ‘Paste Special…’ is a straightforward alternative, but you risk the danger of forgetting to delete the helper value [1] upon completion. Power Query is very powerful, but it makes a copy of the data. With large datasets, this may therefore be an inefficient solution.
Archive and Knowledge Base
This archive of Excel Community content from the ION platform will allow you to read the content of the articles but the functionality on the pages is limited. The ION search box, tags and navigation buttons on the archived pages will not work. Pages will load more slowly than a live website. You may be able to follow links to other articles but if this does not work, please return to the archive search. You can also search our Knowledge Base for access to all articles, new and archived, organised by topic.