Math Column

Perform instant calculations using the data in your app.

The Math Column allows you to perform instant calculations on the data in your table, from basic arithmetic functions to more complex ones. You can then show the output by displaying it in various components in your app.

Math Column in use.

Creating a Math Column

  1. In the Data Editor, open the table you want to edit.

  2. Add a new column by clicking the plus (+) symbol to the right of the table.

    • New columns added with the plus button will always appear on the right. If you'd like to add a column somewhere else in your data, you can select the dropdown menu on an existing column and choose Add column right. You can also click and drag columns to rearrange them.

  3. Name the column.

  4. For Type, search for Math or navigate to Computed -> Math.

  5. Write your calculation or formula in the Configuration field. You can use regular text for this. For example, "price + shipping" (entered without the quotation marks) is all you need to calculate total cost of both price and shipping.

  6. Add Replacements for every word in your configuration. This lets your app know which columns to pull from for each value.

  7. You can specify the precision of decimal points, whether to use a group separator, and if you want to display units as part of the calculated result.

As you start typing in the Configuration field, Glide will guess which column you are referring to and add a new replacement. But you can easily change what is being replaced.

You can also replace parts of your formula with other values such as the values from the User Profile table or the value of Now, which is very useful for date calculations.

Supported Calculations

Simple math

Addition, subtraction, multiplication, division, exponentiation, parenthesis



Date & Time Math

The Math column can also do calculations with dates and times. For example, subtracting two dates/times produces a duration.

Configuring the Date & Time match column.

You can use the Now value to calculate the time until something will happen or how long ago something was.

  1. Now and a Date will give you how long ago a date is (if that date is in the past)

  2. A Date and Now will give you how long until a particular date (if that date is in the future)

When the output of your math column is a date/time value you will also be able to format it.

Formatting the Date & Time Math Column.

Duration value

In Google Sheets, it may not be obvious, but dates are actually stored as numbers. It’s not until cells are formatted as Dates that we can actually read the day, month, year, and time of day from the data.

Date values in Google Sheets are long strings of numbers that represent the number of days since December 31st, 1899. For example, the number 1, when formatted as a date, will display as December 31, 1899.

If you’re working with a value that has a date and time, the Date Value will contain a decimal value that represents the portion of a single day. For example, December 31, 1899 12:00PM would be represented by 1.5 if the cell is formatted as a number.

If you’re working in Microsoft Excel, the Date Value is calculated one day later than in Google Sheets. That is, in Excel, the number 1 represents January 1, 1900 (and not December 31, 1899).

Durations using the Math Column in Glide

In Glide, you can use the Math column to calculate the difference, or duration, between dates. By default, Glide will display the duration in this format: HH:MM:SS (Hours:Minutes:Seconds), which is the same format as you’d see in Google Sheets when formatting as a Duration.

Configuring the duration in hours.

If you need this data to be displayed differently,you can use some familiar Math functions. For example, by using the FLOOR function, we can display the duration as the number of days as opposed to hours.

Configuring the duration in days.

Ways to Use the Math Column

Here are some of the most common ways to use the Math column in your apps beyond simple calculation.

How many days ago/until

As mentioned above, the Now value enables you to calculate the duration between now and the past, or now and the future.

The problem with this, though, is that the output is a duration type, which is not necessarily that readable.

You can use floor() to reduce this to the number of days since/until another date. You can do this by surrounding your original calculation with floor. Now, you can use this value in your app and it will update as time progresses.

Using the FLOOR() function.

Percentage completed

Let’s say you have a project management app with a list of projects and tasks. When someone completes a task, the completed column is marked True.

In the project table, you have a Relation bringing back all the tasks for that project.

First, you create a Rollup using that relation and count all the tasks with the value of true.

Creating a Rollup Column that counts all the tasks with the values of TRUE.

Next, you create another Rollup counting all the unique tasks so you have the total number of tasks in that project (completed or uncompleted).

Creating a Rollup Column that counts all the unique tasks.

Finally, you add a math column that calculates the percentage using the formula Completed/Total*100. Make sure that Completed and Total are replaced by the correct columns.

Adding a Math Column to calculate the percentage.

You can change the precision to 1 and add the percentage sign.

Changing the Precision to 1 and adding the percentage sign.

Now you can add a text component in your app that shows the progress on each project.

Showcasing the Computed Column using the Table Component.

Have a question about Math Column? Ask the Glide community.

Updated more than a week ago
Was this article helpful?