Sub topic 8
Showing thousands and millions with commas
This chapter assumes you can apply a custom format in Format Cells and understand the digit placeholders 0 and # from the previous chapters. It also assumes you know that a format changes only how a value looks, not the value itself.
How a trailing comma scales a number
In a format code, a comma has two jobs, and its position decides which one it does.
- A comma between digit placeholders, as in
#,##0, shows a thousands separator. - A comma after the last digit placeholder divides the displayed number by 1,000. Each additional trailing comma divides by another 1,000.
The scaling affects only the display. The cell still holds the full number, and formulas that refer to it use the full number.
| Format code | Value in cell | Displayed |
|---|---|---|
| `#,##0` | 1234567 | 1,234,567 |
| `#,##0,` | 1234567 | 1,235 |
| `#,##0,,` | 1234567 | 1 |
| `0.0,,` | 1234567 | 1.2 |
Notice that the display is rounded, not cut off. 1,234,567 divided by 1,000 is 1,234.567, which shows as 1,235.
Adding a unit label
A scaled number is easy to misread, so add a label as quoted text. Text in double quotes is shown as a literal.
0.0,,"M"With this format, 1234567 displays as 1.2M. For thousands, use one comma and a K.
#,##0,"K"Here 48500 displays as 49K.
Choosing the scale by size with conditions
You can combine scaling with conditions, which you met in the sections chapter. This format shows millions for large values and thousands for medium ones.
[>=1000000]0.0,,"M";[>=1000]0.0,"K";0- 2500000 displays as 2.5M.
- 48500 displays as 48.5K.
- 750 displays as 750.
A format can hold only two conditions, plus a third section for everything else. That limit is why this pattern stops at millions. You cannot add a billions tier in the same format.
Negative numbers also fall into the last section here, because they match neither condition. They then display without scaling. If your data includes negatives, test them before you rely on the format.
Common mistakes
- Forgetting the scaling is only visual. A cell showing 1.2M still contains 1234567. If you copy it into a report as text, or add it to a total that you expect to be in millions, the sum uses the full values.
- Putting the comma in the wrong place. In
#,##0, the comma is a separator. In#,##0,the final comma scales. A stray trailing comma can divide your numbers by 1,000 without any warning. - Dropping the label. Without
"K"or"M", a reader cannot tell whether 1,235 is the actual value or a scaled one.
Exercises
Exercise
A cell contains 3450000. Write a custom format that displays it as 3.5M, and state what a formula such as =A1*2 returns if A1 holds this value.
Show answer
Use 0.0,,"M". The formula returns 6900000, because the format changes only the display and the cell still stores 3450000.
Exercise
A cell contains 82000 and has the format #,##0,. What does it display, and how would you change the format so a reader knows the unit?
Show answer
It displays 82, because the trailing comma divides by 1,000. Change the format to #,##0,"K" to display 82K.