Help

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

2767 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

My first tip for writing complex Airtable formulas: use an external editor, not the Airtable formula box. I like to use a code editor, but any plain text editor is better than the Airtable formula box.

Yes, you did recommend me the Editor you use earlier a few weeks ago, remember? :winking_face:
If I was still relying Airtable formula box for writing formulas, I would have already ended up in a rehab :winking_face:

Adding comments in formulas with operators +,-,*,/ and with concatenated formulas like “…”&IF(aaa,bbb,ccc) is easy and works well. Turned out to be my favorite undocumented feature of Airtable :winking_face:

More tricky seems are formulas that have many AND and OR arguments that I need to comment. Example:

IF(OR(AND(a=0,b=0,c=0,d=0),OR(e=0,f=0),OR(AND(g=0,h=0,j=0))),"east","west")

I need to add a comment after the string … f=0)

This formula checks for valid (true) result. If you say that IF(X,Y) formula results always in TRUE result, if I put that inside my AND/OR formula, the whole formula may provide incorrect result, because the dummy formula result is always True.

I tried to make something like this here but I am not sure if this is correct logic. Shouldn’t this always result in field result: “east” ?

IF(OR(AND(a=0,b=0,c=0,d=0),OR(e=0,f=0),IF("......this is my dummy formula with a comment.....",0),OR(AND(g=0,h=0,j=0))),"east","west")

Since the dummy formula IF("......this is my dummy formula with a comment.....",0) provides always TRUE response I could put it into another formula that would always generate a FALSE response. Something like this:

IF(OR(AND(a=0,b=0,c=0,d=0),OR(e=0,f=0),AND(IF("......this is my dummy formula with a comment.....",""),0=1),OR(AND(g=0,h=0,j=0))),"east","west")

Am I doing this right?

The “east” and “west” options are just examples. In reality my formula has instead of “east” another formula and it has BLANK() instead of “west”.

Much appreciated and thank you.

OK, scratch that. I found a simple solution.

IF(OR(AND(a=0,b=0,c=0,d=0),OR(e=0,f=0),"......this is my dummy formula with a comment....."="",OR(AND(g=0,h=0,j=0))),"east","west")

I have removed the IF function around my comment and placed the comment into equation “comment”="". The result of this will always be negative so it will not impact my main formula. Done :winking_face:

Kuovonne saves the day again!

Celeste_Bancos
7 - App Architect
7 - App Architect

Another use-case for comments in formula fields is to be able to save snippets of code in formulas that I frequently change.

E.g. I have a little "Blurb" field that I use to format record date when I need to quickly copy a list of records into an email.

The specific fields and formatting that I want depend on the context, so I'm frequently adjusting this formula field on the fly.

 

It would be nice to be able to save little snippets of the formatting code in a comment so I can easily put it back in next time I need it instead of having to generate it from scratch.

Rutger
6 - Interface Innovator
6 - Interface Innovator

I would find this helpful as well.