Its not really possible to be more specific without a lot more information from your side - dimensions and measure for each pie and the output values that you expect. Is timestamp a field, a variable or a literal?
I was thinking of that as a measure - and it is a pattern, so replace the <....> with the relevant expressions from your side. if all the dimensions are the same, then use the same dimension again for the average.
Logic will get you from a to b. Imagination will take you everywhere. - A Einstein