Can I get an average but filter out zeros?

I’m using the following formula to get an average of TradingDuration from the Trade_summary_Date table.

It works correctly, but I’d like it to ignore value of 0 when calculating the average. Can I filter out the zero values in the TradingDuration column?

AVERAGE(Trades_summary_Date.lookupRecords(sort_by = 'Date').TradingDuration) 

This should do the trick:

AVERAGE(td for td in Trades_summary_Date.all.TradingDuration if td != 0)

Incidentally, I removed the lookupRecords with sort_by column, as it’s useless for an average.

Thanks. Good point on the sort. I think I just copied over from another filed and changed it to Average without paying attention