How to handle error with average()

Background
I have a button that fills a column in the current row with an average of a different column in the same table over the last 60 days.
This works great, IF there is data. If not, I get an error saying

Expected at least 1, but got 0 arguments for Average

I don’t want to add a 0 or any other value if there is no average.

How can I only execute this if the average has a value.

hi @Chris_Hall , did you consider to add IfBlank(0) to the list you are evaluating?
in that case the empty items in the list got the value of zero
hope it helps, cheers, christiaan

Thank you for the reply. I did try that, unfortunately, in this case a 0 instead of no value will throw off the averages.

if([ColumnYou'reAveraging].isNotBlank(), [Formula you're currently using], "")

Should do the trick!

1 Like

I see the point
instead of the If statement as proposed by @Billy_Jackson , I’d like to suggest the native coda function AverageIf() which is as you can see a variation on the previous proposal.

cheers, Christiaan

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.