I would like to write the number of values into the legend. How can I use a formula in a custom label?



I would like to add the number of days to the legend of the trendline.

1 Answer 1


The chart editor in google Sheets doesn't allow you to enter formulae or cell references in this way to make chart titles/axes/legends dynamic in this way. There is a partial workaround: if you use a formula to generate the header cell for the data range for your chart which includes a count of the number of values in the column, the series name in the chart editor will update dynamically based on the formula result, and so the legend will also change dynamically. E.g. if the data range was A:B with headers in A1 & B1 and the values you wish to count in B2:B, you could use something like this in B1:

="Range name: ("&count(B2:B)&" values)"

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.