Numbers stored as text? Change a column's data type
Every worksheet column has a data type: numbers, text, or dates and times. The type decides what you can do with the column: only numeric columns can be averaged or charted, and only date columns can be split into weekdays and hours. Change data type converts a column from one type to another. Its most common use is a rescue: a column of measurements that became text because someone typed n/a in one cell.
When to use it
- A numeric column turned into text (its label ends in -T) because of a stray value such as
n/a,<0.5,OOTor a typo. - Dates came in as text, for example from a file with an unusual layout, and you need real dates.
- You want codes such as part numbers or lot numbers treated as labels, not as quantities.
- You need dates as Excel day numbers, or Excel day numbers turned back into dates.
How to do it in StatLab
- Select a cell in the column and choose Data › Change data type….
- Check the Column. The hint under it says what the column holds now, for example Now holds: Text.
- Choose Change to: Numbers, Text or Dates and times.
- Press OK. Results says what changed, and how many values could not be converted. Ctrl+Z undoes it.
What each conversion does:
| From | To | What happens |
|---|---|---|
| Text | Numbers | Each value is read as if you typed it. Values that are not numbers become missing (*), and Results says how many. |
| Text | Dates | Read in your region's date order. Values that are not dates become missing. |
| Numbers or dates | Text | Each value becomes text, written in full as you would type it. |
| Dates | Numbers | Day numbers, as in Excel: 46358.5 is 2 December 2026 at 12:00. |
| Numbers | Dates | Excel day numbers back into dates. |
Example
An assembly cell logs the torque (N·m) of a fastener for each lot. Two cells went wrong: the operator typed n/a for lot L-204, whose part was scrapped before testing, and <12.0 for lot L-206, where the wrench showed a value below its range. The moment n/a was typed, the whole Torque column became text, and a message above the worksheet said so.
Before (Torque is a text column):
| C1-T Lot | C2-T Torque |
|---|---|
| L-201 | 12.4 |
| L-202 | 12.7 |
| L-203 | 12.1 |
| L-204 | n/a |
| L-205 | 12.5 |
| L-206 | <12.0 |
The engineer first thinks about the two text values. n/a really is a missing measurement. <12.0 is not: it says the torque was below 12.0, which is useful information. She notes it in her report and checks the wrench's range, then converts.
In Data › Change data type… she chooses Torque and Change to Numbers. Results: Changed C2-T Torque to numbers. 2 values could not be read and are now missing.
After (Torque is numeric again):
| C1-T Lot | C2 Torque |
|---|---|
| L-201 | 12.4 |
| L-202 | 12.7 |
| L-203 | 12.1 |
| L-204 | * |
| L-205 | 12.5 |
| L-206 | * |
The label is now C2 without -T, and the column can be used in calculations and graphs.
A second case from the same plant: a column Shipped holds dates with times. Converted to Numbers, 2026-12-02 12:00 becomes 46358.5 and 2026-12-01 18:30 becomes 46357.7708333 (the cell shows 12 significant digits). The whole number counts days in Excel's system and the decimal part is the fraction of the day: 18:30 is 0.7708333 of a day.
How to read the results
- Read the count in the Output pane. 2 values could not be read tells you exactly how many cells became missing. If the number is larger than you expected, undo and look at the text values first.
- Check the label. C2 means numeric, C2-T text and C2-D dates.
- Compare a few values with the source. Especially after converting text to dates, check that day and month are the right way round for your region.
Common mistakes
- Converting before looking. Every value that cannot be read becomes missing, and the original text is gone (until you undo). Look at the text values first, and fix the ones that are typos, such as
l2.4with a letter l instead of a one, or12.4 Nmwith the unit typed in. - Treating limit values as missing.
<0.5or>100are censored results, not blanks. Turning them into missing values biases the average upward or downward. Record them separately before converting. - Expecting leading zeros back. Converting a numeric column to text writes
12, not0012: the zeros were lost when the values were read as numbers. Import such codes from an Excel file where they are stored as text, or type them into a text column. - Using day numbers when you need durations. You do not need to convert dates to subtract them. In the calculator,
Shipped - Madegives days directly, and multiplying by 24 gives hours.
Frequently asked questions
Why did my whole column become text when I typed one word?
A column holds one type. Text typed into a numeric column turns the column into text so nothing you typed is lost, and a message says so. Press Ctrl+Z right away to undo, or fix the cell later and change the type back.
What are Excel day numbers?
Excel stores a date as the number of days since 30 December 1899, with the time as a fraction of a day. StatLab uses the same numbers, so 46358 is 2 December 2026 in both.
Can I convert text dates written day-first when my region is month-first?
Text-to-date conversion follows your browser's region. For a file with another date order, import it again and set Dates in the import dialog, or change your browser's region.
Does changing the type change my values?
Only the representation. Numbers converted to text and back are the same numbers. The exceptions are values that cannot be read, which become missing, and leading zeros, which numbers cannot hold.