Use Org mode as an Inline Calculator and Notepad Calculator

October 7, 2022

Use Org mode as an Inline Calculator

If you want to perform some simple calculations you can simply use an Org table and a calc formula.

Let's say you want to calculate the area of a circle. You can do it like this:

| 3.14 | 10 | := $1 * $2^2 |

Which gives you: calculate with inline org table

There is no need to add a table header. However, in some cases, and particularly for future reference it can be a good idea to add it for clarity. Like so:

| pi   | Radius | Area         |
|------+--------+--------------|
| 3.14 | 10     | := $1 * $2^2 |

Which gives: calculate with inline org-table and header

Example - Consultant Income

| *Expected Income*          |                |
| Gross Salary Wanted        | 100000         |
| Health Insurance           | :=0.07 * @2$2  | 
| Pension Plan               | :=0.15 * @2$2  | 
| Total Revenue              | :=vsum(@2..@4) |
| *Hourly rate*              |                |
| Unpaid vacation days       |  20            |
| Public holidays + weekends |  120           |
| Work days per year         | :=365-@7-@8    |
| Work hours per year        | :=@9 * 8       |
| Rate needed                | :=@2 / @10     |

The above calculations gives:

calculate org-mode spreadsheet

Using variables - Notepad Calculations

It's also possible to use variables to easier refer to data in a cell. Instead of refering to cells by using the row and column specifications (eg. @2$2), you can use a variable name defined in the column to the right of the value cell.

This would result into something similar to a Soulver notepad.

Below is the same example as above, but with variables:

| *Expected Income*         |                               |  
| Gross_Salary_Wanted       | 100000                        | 
| Health_Insurance          | :=0.07 * Gross_Salary_Wanted  |  
| Pension_Plan              | :=0.15 * Gross_Salary_Wanted  | 
| Total Revenue             | :=vsum(@2..@4)                |
| *Hourly rate*             |                               |
| Unpaid_vacation_days      |  20                           |
| PublicHolidaysAndWeekends |  120                          |
| Work_days_per_year        | :=365 - Unpaid_vacation_days - PublicHolidaysAndWeekends  |
| Work_hours_per_year       | :=Work_days_per_year*8        |
| Rate needed               | :=Gross_Salary_Wanted/Work_hours_per_year |

And here is the result which is more or less the same as before except for the variable names used:

org-mode spreadsheet with vaiables

Please note that variable names can only consist of upper and lower case letters and underscore (_).

Subscribe to our newsletter

Join us today and receive updates on new features and changelogs!

No spam, unsubscribe at any time.
Check out our Privacy Policy.