Values & types - Coding concepts using Sheets

I'm writing a series of posts to explain basic coding concepts using Google Sheets. In this post, I will explain what a value is and I will also introduce the concept of a data type.

Values are the data used by a computer program

A spreadsheet is very similar to a computer program in that you have input data that you analyze or process (usually via formulas) to generate some output data.

Consider a spreadsheet containing the names, birthdays and test scores of 3 students. These would be the input data or input values. When you use the [code]AVERAGE()[/code] function to calculate the average test score, you're generating an output value using your "spreadsheet program".

Values have types

In Google Sheets, every value has a type. Some of the common types are:

  • Numbers

  • Text

  • Boolean (true or false)

In many programming languages, these types are also known as "data types". The number of supported types can vary from one programming language to another but the concept (of a data type) itself can be found in most programming languages.

[note]

Dates are numeric values

In Google Sheets, dates and time are internally stored as numeric values even though they are formatted as dates when displayed to you.

[/note]

You can use the [code]TYPE()[/code] function to find out the type of a value. This function returns

  • 1 if the value is a number

  • 2 if the value is text

  • 4 if the value is boolean

Value

Type of value

=TYPE()

Notes

100

Numeric

1

John Ramsey

Text

2

10/9/2015

Numeric

1

Dates are numeric values under the hood.

TRUE

Boolean

4

Most programming languages have some way to find out the type of a value. For example, in Apps Script, you can find out the type of a value using the [code]typeof[/code] operator.

Logger.log(typeof 2);

Master Google Sheets Automation

Sign up to receive exclusive Automation tips and tutorials!
I'll send you actionable tips on automating tasks with Google Sheets and coding with Apps Script. You'll also be notified whenever new content is published.
PLUS: Get instant access to my Birthday Reminder Template! 🎂
By signing up you agree to the Privacy Policy & Terms.

Have feedback for me?

I'd appreciate any feedback you can give me regarding this post.

Was it useful? Are there any errors or was something confusing? Would you like me to write a post about a related topic? Any other feedback is also welcome. Thank you so much!