Help

Trigonometry Formula Script

1591 2
cancel
Showing results for 
Search instead for 
Did you mean: 
Systr4n
4 - Data Explorer
4 - Data Explorer

Greetings

I wanted to make a formula as follows:

X= {X1}+{distance}*sin({alpha})*cos({beta})

I think there are no trig functions in airtable except in scripting.

Can anybody help me with the coding of such a script?

 

Thank you

2 Replies 2

You are correct that Airtable currently does not have formula functions for trig. 

What type of help are you looking for ...
- Are you new to coding and want help learning to write a script?
- Do you have experience writing code, but haven't worked with trig functions before? If so, look into Math.sin() and Math.cos(). Airtable scripts have access to the JavaScript Math object.
- Do you want someone to write the script for you? If so, do you have budget?

Some additional considerations for the script ...
- do you want the script to run off an automation, interface button, button field, or something else?
- do you want the script to process only a triggering record, or all the records in a view?
- do you want the script to calculate only sine/cosine and have a formula do the rest? Or do you want the script to calculate X.
- are your angles entered in radians or degrees? (If they are degrees, you will need to convert to radians.)
- can you provide sample data, including all inputs and expected outputs?

It's unfortunate that we can't do such calculations within a Formula Field. Definitely post a suggestion to Airtable support requesting such features, I think they'd be overly useful.

Until then, you'll need to either use a Script Extension, or an Automation with a Script action - as both of these use JavaScript, if this is your first time using JavaScript then have a read of this article, as it might aid you with understanding the challenge that awaits!

https://www.digitalocean.com/community/tutorials/how-to-do-math-in-javascript-with-operators

There's a lot of support to be had on these community forums, just reach out with any questions that you may have.