Hi:
I have the following query for getting averaged records by the week.
SELECT [Week], WeekTotal, WeekRecords, WeekTotal/WeekRecords AS WeekAvg FROM
(SELECT format([Date], "ww"
AS [Week], SUM([1]+[2]+[3]+[4]+[5]+[6]+[7]+[8]+[9]+[10]+[11]+[12]+[13]+[14]+[15]+[16]+[17]+[18]+[19]+[20]+[21]+[22]+[23]+[24]+[25]+[26]+[27]+[28]+[29]+[30]+[31]+[32]+[33]+[34]+[35]+[36]+[37]+[38]+[39]+[40]+[41]+[42]+[43]+[44]+[45]+[46]+[47]+[48]+[49]+[50])
AS WeekTotal, COUNT(*) AS WeekRecords
FROM TargetSheetData
GROUP BY format([Date], "ww"
)
ORDER BY [Week]
However, it doesn't seem to be working quite right.
Also, I need the WeekAvg to return as the sum of all records divided by the count of all records.
In other words, if the WeekTotal is 100 and the number of records for that week is 50 then the average I need would be 2.0.
My reports use the following expression to get the average I need:
=((NZ(Sum([1]))+NZ(Sum([2]))+NZ(Sum([3]))+NZ(Sum([4]))+NZ(Sum([5]))+NZ(Sum([6]))+NZ(Sum([7]))+NZ(Sum([8]))+NZ(Sum([9]))+NZ(Sum([10]))+NZ(Sum([11]))+NZ(Sum([12]))+NZ(Sum([13]))+NZ(Sum([14]))+NZ(Sum([15]))+NZ(Sum([16]))+NZ(Sum([17]))+NZ(Sum([18]))+NZ(Sum([19]))+NZ(Sum([20]))+NZ(Sum([21]))+NZ(Sum([22]))+NZ(Sum([23]))+NZ(Sum([24]))+NZ(Sum([25]))+NZ(Sum([26]))+NZ(Sum([27]))+NZ(Sum([28]))+NZ(Sum([29]))+NZ(Sum([30]))+NZ(Sum([31]))+NZ(Sum([32]))+NZ(Sum([33]))+NZ(Sum([34]))+NZ(Sum([35]))+NZ(Sum([36]))+NZ(Sum([37]))+NZ(Sum([38]))+NZ(Sum([39]))+NZ(Sum([40]))+NZ(Sum([41]))+NZ(Sum([42]))+NZ(Sum([43]))+NZ(Sum([44]))+NZ(Sum([45]))+NZ(Sum([46]))+NZ(Sum([47]))+NZ(Sum([48]))+NZ(Sum([49]))+NZ(Sum([50])))/(Count([1])+Count([2])+Count([3])+Count([4])+Count([5])+Count([6])+Count([7])+Count([8])+Count([9])+Count([10])+Count([11])+Count([12])+Count([13])+Count([14])+Count+([15])+Count([16])+Count([17])+Count([18])+Count([19])+Count([20])+Count([21])+Count([22])+Count([23])+Count([24])+Count([25])+Count([26])+Count([27])+Count([28])+Count([29])+Count([30])+Count([31])+Count([32])+Count([33])+Count([34])+Count([35])+Count([36])+Count([37])+Count([38])+Count([39])+Count([40])+Count([41])+Count([42])+Count([43])+Count([44])+Count([45])+Count([46])+Count([47])+Count([48])+Count([49])+Count([50])))
Should I use this in the query?
Thanks,
xeb
I have the following query for getting averaged records by the week.
SELECT [Week], WeekTotal, WeekRecords, WeekTotal/WeekRecords AS WeekAvg FROM
(SELECT format([Date], "ww"
AS WeekTotal, COUNT(*) AS WeekRecords
FROM TargetSheetData
GROUP BY format([Date], "ww"
ORDER BY [Week]
However, it doesn't seem to be working quite right.
Also, I need the WeekAvg to return as the sum of all records divided by the count of all records.
In other words, if the WeekTotal is 100 and the number of records for that week is 50 then the average I need would be 2.0.
My reports use the following expression to get the average I need:
=((NZ(Sum([1]))+NZ(Sum([2]))+NZ(Sum([3]))+NZ(Sum([4]))+NZ(Sum([5]))+NZ(Sum([6]))+NZ(Sum([7]))+NZ(Sum([8]))+NZ(Sum([9]))+NZ(Sum([10]))+NZ(Sum([11]))+NZ(Sum([12]))+NZ(Sum([13]))+NZ(Sum([14]))+NZ(Sum([15]))+NZ(Sum([16]))+NZ(Sum([17]))+NZ(Sum([18]))+NZ(Sum([19]))+NZ(Sum([20]))+NZ(Sum([21]))+NZ(Sum([22]))+NZ(Sum([23]))+NZ(Sum([24]))+NZ(Sum([25]))+NZ(Sum([26]))+NZ(Sum([27]))+NZ(Sum([28]))+NZ(Sum([29]))+NZ(Sum([30]))+NZ(Sum([31]))+NZ(Sum([32]))+NZ(Sum([33]))+NZ(Sum([34]))+NZ(Sum([35]))+NZ(Sum([36]))+NZ(Sum([37]))+NZ(Sum([38]))+NZ(Sum([39]))+NZ(Sum([40]))+NZ(Sum([41]))+NZ(Sum([42]))+NZ(Sum([43]))+NZ(Sum([44]))+NZ(Sum([45]))+NZ(Sum([46]))+NZ(Sum([47]))+NZ(Sum([48]))+NZ(Sum([49]))+NZ(Sum([50])))/(Count([1])+Count([2])+Count([3])+Count([4])+Count([5])+Count([6])+Count([7])+Count([8])+Count([9])+Count([10])+Count([11])+Count([12])+Count([13])+Count([14])+Count+([15])+Count([16])+Count([17])+Count([18])+Count([19])+Count([20])+Count([21])+Count([22])+Count([23])+Count([24])+Count([25])+Count([26])+Count([27])+Count([28])+Count([29])+Count([30])+Count([31])+Count([32])+Count([33])+Count([34])+Count([35])+Count([36])+Count([37])+Count([38])+Count([39])+Count([40])+Count([41])+Count([42])+Count([43])+Count([44])+Count([45])+Count([46])+Count([47])+Count([48])+Count([49])+Count([50])))
Should I use this in the query?
Thanks,
xeb