I have a crosstab query that returns averages by month.
I want to add a final column that contains the average of the averages. (I know that this is not generally a sound practice, but there is a reason)
The current output looks like
action_type, worker_type april may june
initial lead 10 20 30
I'd like it to look like
action_type, worker_type april may june Avg
initial lead 10 20 30 20
The issue I've hit is that I cannot simpy use ([april] + [may] + [june])/3 to get the averages because the names of the months will change every quarter. (There is an inner query that groups on month)
My current code is below
PARAMETERS [Enter start date] DateTime, [Enter end date] DateTime;
TRANSFORM Round(Avg([MainUnionQuery].[Expr1]),2) AS [Avg]
SELECT ActionType, WorkerType
FROM MainUnionQuery
GROUP BY ActionType, WorkerType
PIVOT MainUnionQuery.Month;
I want to add a final column that contains the average of the averages. (I know that this is not generally a sound practice, but there is a reason)
The current output looks like
action_type, worker_type april may june
initial lead 10 20 30
I'd like it to look like
action_type, worker_type april may june Avg
initial lead 10 20 30 20
The issue I've hit is that I cannot simpy use ([april] + [may] + [june])/3 to get the averages because the names of the months will change every quarter. (There is an inner query that groups on month)
My current code is below
PARAMETERS [Enter start date] DateTime, [Enter end date] DateTime;
TRANSFORM Round(Avg([MainUnionQuery].[Expr1]),2) AS [Avg]
SELECT ActionType, WorkerType
FROM MainUnionQuery
GROUP BY ActionType, WorkerType
PIVOT MainUnionQuery.Month;