Rule with average

See this post, maybe it helps.