Ability to comment out lines inside formula / calculation

Some formulas get very complex and I’d like to be able to add comments inline (just like you would by using // in javascript or <!-- in html) to give context on why certain formula logic is done the way it is, or so you can quickly test different formulas without having to remove unused logic each time.

I know there’s already a description field, but that is for the entire formula and doesn’t provide the specific line-by-line context I’m sometimes looking for.

Hi,

I agree that comments inside formulas are very helpful, whether for complex, long formulas, or to just test/debug by disabling parts of it.

Unfortunately for the time being, before such a feature is implemented, I have had to resort to wasting a bit fo computing power to have at least single-line comments or to comment entire sections out.

I do not recommend it, unless it is absolutely needed, but you could surround your comment with a LEFT or RIGHT function with its secone argument set to 0. Of course, you would have to be careful with the return type of what you are commenting out, and possibly use ToText on it before passing it to LEFT or RIGHT.

For instance, instead of comments like these, which are not supported:

// This is a comment.
-- or --
/*
If(IsEmpty(SomeField),
  SomeFunction(SomeArg) +
  AnotherFunction(AnotherArg),
  "Already exists"
)
*/

You would write:

LEFT("This is a comment.",0)
-- or --
LEFT(
  If(IsEmpty(SomeField),
    SomeFunction(SomeArg) +
    AnotherFunction(AnotherArg),
    "Already exists"
  )
,0)

I would suggest adding some marker(s) and parentheses when needed, to distinguish comments from real LEFT/RIGHT functions, and make it easiler to see them visually, such as:

LEFT("COMMENT: This is a comment.",0)
-- or --
LEFT("COMMENTSTART:" +(
  If(IsEmpty(SomeField),
    SomeFunction(SomeArg) +
    AnotherFunction(AnotherArg),
    "Already exists"
  )
)+":COMMENTEND",0)

Important: It is wasteful, since it causes actual computing to comment somethign out, but when absolutely needed, or temporarily used for testing/debugging shoudl be fine.

1 Like