Got it! Dsum worked. Why would it treat DSum differently from Sum? The
error message I had received before was "Subqueries cannot be used in the
expression ([Expr1]/(Sum([Expr1])). Attached is my code (working!) with
the
Dsum expression (Expr6):
SELECT tblSTYLE.STYLE, source.Code, source.Name, performance.ce1,
performance.eq1, performance.fi1, source.Cash, source.Equities,
source.Fixed,
Sum([Cash]+[Equities]+[Fixed]) AS Expr1, [Cash]/[Expr1] AS Expr2,
[Equities]/[Expr1] AS Expr3, [Fixed]/[Expr1] AS Expr4,
([ce1]*[Expr2])+([eq1]*[Expr3])+([fi1]*[Expr4]) AS Expr5,
[expr1]/(DSum("[expr1]","qryPerfSmCap")) AS Expr6
FROM (codes INNER JOIN (source INNER JOIN performance ON source.Code =
performance.NUMBER) ON (codes.NUMBER = source.Code) AND (codes.NUMBER =
performance.NUMBER)) INNER JOIN tblSTYLE ON codes.[OPT# CAT- 18] =
tblSTYLE.OPTICODE
GROUP BY tblSTYLE.STYLE, source.Code, source.Name, performance.ce1,
performance.eq1, performance.fi1, source.Cash, source.Equities,
source.Fixed
HAVING (((tblSTYLE.STYLE)="smallcap"));
It's a select query.
Many thanks for your time!!!
-Russ
Ken Snell said:
What is the specific error message that you get? Is your query a select
query? or an action query?
Have you tried using DCount or DSum domain function to get the
"denominator"
of the expression?
We may need to see the SQL statement (even if "ugly") to better
understand
what you're trying to do.
--
Ken Snell
<MS ACCESS MVP>
RussG said:
The query SQL is admittedly quite ugly, I'll spare you the full code.
Basically, data from linked tables are:
Account #
Account Type (several fields)
Account Values (several fields, by asset type)
Account Returns (several fields, by asset type)
My query is mostly Expressions used to calculate returns by asset type.
But
I would like to generate Total Weighted Returns (by asset type), and to
do
that I need Percentage of Total. As was already suggested, I tried
generating the individual records' percentage of total in a separate
query,
and then link the queries, but I still received a "subquery" error
message.
Hope this is helpful.
:
Can you tell us just a little bit more about what your data are? and
the
table structure? and the query SQL statement? and such?
--
Ken Snell
<MS ACCESS MVP>
I think this is so simple, yet alas...
What I am tring to do is create the expression: [Expr1]/sum[Expr1]
to
give
me percentage of total for individual records. Access gives me a
"subquery"
warning. Any workaround? As always, your insight is
appreciated!!!