# Calculations (formula) - help needed

Hi,
please, can anyone here help me to set up properly some calculation fields (formula) in my table?

Let’s say I have a table with student’s names where one of my columns (fields) is a number type, where I put manually the year, when student finished his exam (or let’s say he finished the high scool). I will name this field as “EXAM”.

I would like to create two more fields:
One field - I will call it “CALC”- auto-calculated, where number 25 is subtracted from the “EXAM” field and result is displayed here.
And then another field (I will call it “CALC2”), which will use actual year as an input number (so just now it would be a number 2023, but next year it will be number 2024) and then the number from “CALC” field will be substracted from it and will display the result number.

Example:
if I will put the number 2015 in the “EXAM” field, then in “CALC” field I should see the number 1990 and in “CALC2” field I should see the number 33.

One more thing: if the “EXAM” field is empty, then no calculations should be done.

Thanks!

Hello @marcus, here you are: Grid // Baserow.

Field CALC: formula `field('Exam') - 25`
Field CALC2: formula `year(now()) - field('CALC')`

Hope it helps

Great, works. Thanks for it.
Just one more thing: how can I add the exception to CALC anc CALC2 fields? I mean, if EXAM field is empty, then also fields CALC and CALC2 should be empty too.

Hey, you can achieve that by using functions `if` and `is_null`, here’s how it works: Grid // Baserow.

Field CALC: `if(is_null(field('Exam')), '', field('Exam') - 25 )`
Field CALC2: `if(is_null(field('Exam')), '', year(now()) - field('CALC'))`

Hi Olga, wonderful, thanks for your help.

First formula works correctly, but second formula

``````if(is_null(field('Exam')), '', year(now()) - field('CALC'))
``````

which is for field CALC2 - - gives me this error: Error with formula: argument number 2 given to operator - was of type text but the only usable type for this argument is number.
It looks like the problem is that field CALC is formula type, but formula function expects (requires) standard number filed type. It’s silly, but if it’s like that, then I need some workaround for it.