Data types and formatting

1. Data types and formatting

So far,

2. Google Sheet data types

we've worked with Google Sheets that contained a few different types of data, including: numbers, text, dates, and currencies. In Google Sheets, every cell value has a data type.

3. Google Sheet data types

When entering a value, like a number or some text, the spreadsheet will automatically assign a data type to the cell. This assigned data type might not always be appropriate, so we can also manually assign the data type. Ensuring that your cells have the correct data type is crucial, as the data type determines what operations can be performed on the cell, and how the value will be displayed in the spreadsheet.

4. Data type: Number

We've worked with a lot of numbers so far, and any number inputted into a cell will be automatically assigned the number data type. Numbers support arithmetic operations, along with other statistical operations that are outside the scope of this course. By default, numerical data is right-aligned in the cell.

5. Changing decimal places

At times, we may want to specify how our numerical data is displayed. For example, if we want to calculate the average number of children per school class, we may choose to report a result rounded to the nearest whole number, or zero decimal places. This can be achieved using the Google Sheets toolbar. The two buttons highlighted can increase or decrease the number of decimal places displayed. Let's try this on the Interest Rate column.

6. Reducing decimal places

Selecting the Decrease decimal places button reduces the decimal places by one, rounding cell D4 from 0.85 to 0.9.

7. Adding decimal places

Increasing the number of decimal places by one doesn't provide any extra precision in this case, but extra zeros were added to the end of each result.

8. Data type: Plain text

Cell values are assigned the plain text data type if no other data types are detected. We can force a cell to be plain text data by either changing it in the Format menu,

9. Data type: Plain text

or as a shortcut, by prepending the cell contents with a single quote. For example, a single quote followed by a 2 will display the number two as plain text. Similarly, a single quote followed by a formula will instead store the formula as text, rather than evaluating it. By default, text data is always left-aligned.

10. Data type: Date

There are lots of ways of specifying dates, and Google Sheets will correctly detect many of them automatically. We can also manually specify or convert date formats using the format menu, and selecting Number. We can see that there are several options, but custom formats can also be written. Like numbers, dates are right-aligned, by default.

11. Data type: Currency

Google Sheets are excellent at detecting currencies. Any cell starting with a currency symbol, followed by a number, will be assigned the Currency data type. As currencies are a type of numerical data, Google Sheets right-aligns them.

12. Data type: Logical

One key data type that we haven't seen up to this point, is the logical data type. There are only two logical values: TRUE and FALSE, which are also referred to as Boolean values. Logical values are case-sensitive, and if we tried typing true or false in different cases, the spreadsheet will convert it to uppercase. Logical values are center-aligned by default.

13. Comparison operators

Logical values are often returned by formulas that include comparison operators. Google Sheets supports several comparison operations, including equal to, not equal to, greater than, less than, greater than or equal to, and less than or equal to. Each is used by starting a formula with an equals, then a value or expression, a comparison operator, and a second value or expression to compare against. In each case, the formula returns a logical TRUE or FALSE value depending on how the expression was evaluated.

14. Let's practice!

Time for some exercises!