I suggest not using the attr() function like this as this is an aggregate calculation. the value is going across many rows. Can you share a small sample workbook of data with the community?
thanks Pattrick, but i get an error of mixing aggs and non-aggs. whats is another option?