Skip to main content

Execute Calculations in Amount Fields

Every amount field in SoftLedger accepts spreadsheet-style formulas. Start the field with =, type an expression like =1000/3 or =(100+50)*2, and when you leave the field it stores the calculated number.

Written by Travis Lander

Overview

Every amount field in SoftLedger accepts spreadsheet-style formulas. Start the field with =, type an expression like =1000/3 or =(100+50)*2, and when you leave the field it stores the calculated number. Only the result is saved — rounded exactly as if you had typed it — so there's nothing to recalculate later and no formulas hiding in your records.

Without the leading =, fields behave exactly as they always have: type a number and it's stored. And if you type something like 10+10 without the =, the field holds your text and prompts you to add it — a stray keystroke can never be saved as 1010.


Where it works

Every money field and number field in the web app uses the same input, so the behavior is identical everywhere:

Field type

Examples

Money fields

Journal debits and credits, invoice and bill line amounts, tax amounts, sales order and purchase order lines, payment and cash receipt amounts, fixed asset costs and schedules, prepaid schedules, item prices

Number fields

Quantities, exchange rates, unit costs, vendor prices, stock counts

Note: Formulas are a web app convenience. The API accepts numbers only, and bulk upload spreadsheets are read as values — use your spreadsheet's own formulas there.


The basics

Start with = and write it the way you would in a spreadsheet:

You type

Field stores

Notes

=1000/3

333.33

Rounded to the currency's decimal places

=(100+50)*2

300.00

Parentheses group, nesting is fine

=-(10+5)

(15.00)

Negate a group

=1,000.50*2

2,001.00

Thousands separators are ignored

=1.5k

1,500.00

k for thousands, m for millions

=2M+1.5K

2,001,500.00

Either case works

Operators follow the usual precedence: * and / before + and -.

One thing to know about negatives: accounting parentheses mean a negative only in a plain entry. Typing (100) stores (100.00), but inside a formula parentheses group, so =(100) is positive 100. Type =-100 for a negative.


Percentages

Put % after a number and it behaves the way an accountant would expect:

  • Added to or subtracted from a value, it's a percentage of that value — the way the % key works on a calculator, and the natural reading for tax and markup.

  • Anywhere else, it's a plain fraction10% is 0.1.

You type

Field stores

Reading

=500+8.25%

541.25

500 plus 8.25% of 500

=500-10%

450.00

500 less 10% of 500

=100-10%-10%

81.00

Compounding — each step is a percentage of the running value

=1000*10%

100.00

10% of 1000

Differs from Excel: Excel reads =500+8.25% as 500.0825 because it treats the percentage as a plain fraction everywhere. SoftLedger stores 541.25. If you want the Excel result, write =500+0.0825 or =500+(8.25%).


Referring to other lines

On forms with a lines table, a formula can use values from the other lines. Names aren't case sensitive.

Journal entries (debit and credit cells):

Name

Value

D1, D2, ...

Debit of that line

C1, C2, ...

Credit of that line

DEBITS

Total of all debits

CREDITS

Total of all credits

Invoices, bills, sales orders, and purchase orders (line amount and tax amount cells on the create and edit forms):

Name

Value

QTY

This line's quantity

A1, A2, ...

Amount (unit price) of that line

Q1, Q2, ...

Quantity of that line

SUBTOTAL

Sum of quantity × amount across all lines, before tax

Some favorites:

Where

You type

Result

Journal, line 2 debit

=D1*20%

20% of line 1's debit

Journal, last line credit

=DEBITS-CREDITS

Whatever is needed to balance the entry

Invoice line amount

=1200/QTY

The unit price that makes the line total 1,200

Bill line amount

=SUBTOTAL*2.5%

A 2.5% freight or handling line

A few rules to keep in mind:

  • Line numbers start at 1 and follow the order on screen. Empty cells count as zero.

  • References are read once, when you leave the field. Changing line 1 later doesn't update line 2 — the number is stored, not the link.

  • Same form only. There's no way to reference another journal, document, or account balance.

  • References aren't available yet on the card-style line editors of saved documents, prepaid and fixed asset schedule lines, or the location allocation table.


Paste a column, get a sum

Copy a column of amounts from a bank statement or spreadsheet and paste it into an amount field. The values are joined into a sum formula you can see and edit before committing:

You paste

Field shows

Field stores

100 200 300

=100+200+300

600.00

($1,200) (50) $25.50

=-1200-50+25.5

(1,224.50)

Currency symbols are stripped, header rows and blanks are skipped, and pasting into a field that already holds an amount appends to it with +. Just make sure it's a numeric column — dates or codes will be read as digits.


While you're typing

  • Live result — as you type a formula, the result shows under the field, rounded as it will be stored.

  • Formula hint — after you commit, the expression stays visible under the field (= 1000/3) until the amount changes, so you can see how the number was arrived at. It isn't saved with the record.

  • Enter commits the field — Enter behaves like Tab. It no longer submits the form from an amount field.

  • Escape reverts — if you've changed the field, Escape restores the value it had when you clicked in.


If a formula can't be evaluated

A formula that can't be evaluated is never stored as a number. Your text stays in the field with a message under it, and the previous amount is kept until you fix or clear it — so watch for the red message before saving.

Message

Cause

Invalid formula

Malformed expression, unbalanced parentheses, or unsupported characters

Cannot divide by zero

A divisor evaluates to zero, like =100/(5-5)

Unknown reference: D9

A name that doesn't exist on this form, or a line number past the last line

Start with = to enter a formula

An operator was typed without the leading =


Rounding and precision

  • Math is exact — no floating point drift. =0.1+0.2 is exactly 0.3.

  • The result is rounded once, when stored, to the currency's decimal places (round half up). Intermediate results aren't rounded: =1000/3*3 stores 1,000.00.

  • Number fields like quantities and rates keep up to ten decimal places.


Good to know

  • No functions. ROUND, SUM, ABS, and the like aren't available — this is a calculator, not a spreadsheet.

  • No exponents or scientific notation. Use =1m or =1000000, not 1e6.

  • Commas are thousands separators only. The decimal separator is always ..

  • Currency symbols can't be typed in a formula. =$100+5 is invalid (pasted columns are the exception — symbols are stripped automatically).

  • Two numbers need an operator between them. =10 5 is invalid, though spaces around operators are fine.


Worked examples

Split an expense 60/40 and balance the entry. Line 1 debit =1250*60% stores 750.00. Line 2 debit =1250-D1 stores 500.00. Line 3 credit =DEBITS stores 1,250.00.

Enter a tax-inclusive amount, then back the tax out. =500+8.25% stores 541.25, and =541.25/1.0825 elsewhere stores 500.00.

Set a unit price from a quoted line total. With a quantity of 3, a line amount of =1200/QTY stores 400.00.

Total a bank statement column. Copy the amounts, click into the cash receipt amount, paste, and press Enter.

Enter thousands with shorthand. =45.2k stores 45,200.00.

Did this answer your question?