Help

Re: Is it possible to make comments within a formula?

5082 0
cancel
Showing results for 
Search instead for 
Did you mean: 
RJ_Martino
5 - Automation Enthusiast
5 - Automation Enthusiast

Can you make a single line comments within a formula?

16 Replies 16

No, you cannot make comments in a formula field.

If you have a particularly complex formula that you might need to adjust later, you should probably document it elsewhere.

If the formula is a calculation based on inputted values that will never change, consider shifting the logic to the Scripting block. You can include comments in the JavaScript. One disadvantage is that you will still have to manually run the Scripting block.

Paul_Warren
8 - Airtable Astronomer
8 - Airtable Astronomer

This would be a useful feature! Complex formulas to help create views can be confusing and make it difficult to adjust in the future. Not my highest priority feature, but would be nice.

Would love this! Please add to the Product Suggestions topic!

TFP
6 - Interface Innovator
6 - Interface Innovator

This would really be a useful addition to make complex formulas easier to understand.

Was just going to search for answer how to do this and this post came out on top search results. Right on. Yes exactly this is what we need.

I have many fields with massive formulas, about 1-2 letter size pages printed in regular font and I can’t break them down because I am running out of fields in Airtable (500 fields limit). So now I am getting headache of the super long formulas.

Being able to put comments like ** THIS IS A COMMENT ** or /// THIS IS A COMMENT \\ would be fantastic.

(I can’t put the formulas in scripts, first I have no idea about programming and secondly the formulas use 100’s of fields in the table so values constantly change)

While you still cannot make an official comment in a formula, I use this workaround to comment more complex formulas:

For example, if my formula is …

{lookup field} & ""

I can comment it like this …

IF(
    "convert lookup value to a string",
    {lookup field} & ""
)

I also use this technique to document “magic numbers” in formulas:

IF(
    "circumference = 2 * radius * pi, where pi is 3.14",
    2 * {radius} * 3.14
)

This workaround takes advantage of the fact that the string will always evaluate as true. When properly used, this technique also does not affect the resulting data type of the formula.

Keep in mind that this technique adds extra calculation time to the formula, which may already take a long time to calculate. If the formula is approaching the undocumented formula limits, you may also need to take care in adding branches to the formula just for the sake of comments.

Interesting, this will definitively help to add comments to remind myself what is the purpose of things in the formula. Now I actually realize I could add some dummy formulas to that like…

IF ( “…this is some comment for the next section in the formula …”,0,0)

… if it is surrounded by + or - signs

or

IF ( “…this is some comment for the next section in the formula …”,1,1)

… if it is surrounded by * or / signs

Great. At least something.

Also - I need to get used to use spaces in Airtable. I am used to use formulas in Excel and there are no spaces allowed so old habits never die and always keep working without spaces out of fear something will break some day if I have spaces in Airtable. Are spaces completely safe?

White space (spaces, new lines, etc.) are safe between elements in a formula. For example, between a field name and an operator.

White space is not allowed between a function name and the opening parenthesis. For example, this is not valid:
IF ( "This is not allowed", 1, 1)

These are the best tips since long time, the Airtable formula box is a dragon that keeps chasing me :winking_face: