"AccessARS"wrote:
I am running a query off of a query where I am attempting to get a
percentage of a field next to a record from the sum of the same field from
the source query...
My string:
SELECT qry_TurnoverChartLevel1.EmployeeLevel,
Sum(qry_TurnoverChartLevel1.CountOfEmployeeLevel) AS
SumOfCountOfEmployeeLevel,
DSum([CountOfEmployeeLevel],[qry_TurnoverChartLevel1])/[CountOfEmployeeLevel]
AS [Level%]
FROM qry_TurnoverChartLevel1
GROUP BY qry_TurnoverChartLevel1.EmployeeLevel;
My Error:
You tired to execute a query that does not inlude the specified function
'DSum([CountOfEmployeeLevel],[qry_TurnoverChartLevel1])/[CountOfEmployeeLevel]'
as part of an aggregate function.
I know from experience it is tough to ask a question
on these newsgroups. If you give too much details
you suspect their eyes will just glaze over and move
on. If you don't give enough detail (they cannot see
your data), they may not be able to zero in on your
problem and you end up with a discussion tree just
sorting out the details which can be frustrating for
both parties.
So...here's a guess and maybe we'll get lucky this time...
Domain functions can be "expensive," but it appears
in this case you just want to sum all the counts in your
query? Is there any reason this could not have been
already determined in qry_TurnoverChartLevel1?
Nevertheless...
I could be wrong but I think if you give the DSUM
its own column in the query grid, and give it an alias, and
set "Total" row to "Expression," it will be executed
only once over query execution. Also, in domain functions the
"expr" and "domain" need to be wrapped in quotes.
So (if we're lucky) your query grid might look like:
Field: TotCnt:
DSum("CountOfEmployeeLevel","qry_TurnoverChartLevel1")
Table:
Total: Expression
Sort:
Show:
Criteria:
or:
followed by the calculation column using our "TotCnt" alias:
(always good idea to not introduce punctuation in
your field names)
Field: LevelPerCent : IIF([CountOfEmployeeLevel]<>0,
[TotCnt] / [CountOfEmployeeLevel], 0)
Table:
Total: Expression
Sort:
Show:
Criteria:
or:
{above Field lines may word wrap here,
but should all be typed out all on one line}
good luck,
gary