Hi hmax
Unless I am missing something I can see no reason why you would need to use variables at all. The detail formula could just be:
datediff("s",{Command.CREATION_DATE}, {Command.CLOSED_DTTM}
(or better still, move the calculation to the Command and have the database server do the calculation for you), and then you could just use the normal Average summary to provide that calculation in the footer.