The GROUP BY can stand on it's own like you have done. It has to be at the end of a LOAD statement. You don't have a load statement that you show in the snippet above. Could you share the load statement where you want to use the
$(vModifiedDate) - $(vOpenDate) AS Avg_Time where also the GROUP BY needs to be at the end.