0

This question is similar to mine, but all the answers assume that the output of the original formula is a number.

What if I want to add a comment to a query formula that outputs an array of strings and numbers? Would there be a way to add a comment to it?

1
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
    – Community Bot
    Sep 17, 2021 at 16:33

2 Answers 2

0

You can use the iferror() function to write a comment combined with an operation that is guaranteed to produce an error, such as divide by zero, and place the original formula as the second parameter in the iferror(), like this:

=iferror( "this is a comment"/0, query(A1:C, "select A, C", 1) )

2
  • Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the How to Answer. Sep 17, 2021 at 16:38
  • Yes... added an explanation. It feels a bit artificial though. Function documentation is readily available in the formula editor, and divide by zero is a well known error. Sep 17, 2021 at 17:58
1

From https://www.benlcollins.com/spreadsheets/google-sheets-formulas-techniques/

Add comments to your formulas, using the N function. N returns the argument provided as a number. If the argument is text, inside quotation marks, the N function returns 0.

So we can use it to add a comment like this:

=SUM(A1:A100) + N("Sums the first 100 rows of column A") 

which is effectively the same as:

=SUM(A1:A100) + 0 

which is just:

=SUM(A1:A100) 

And from How to add a note or comment into a formula in Google Sheets?

For formulas that generate text, you can add T() around the N() function:

="…" & T(N("your comment here")) 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.