Calculations can have conditional expressions, example - a calculation that would apply to each row:
[field2] * IIf([field1]="A", 0.10, 0.05)
However, if you want Access to aggregate records only if the value is prime, how would Access 'know' the value is prime? Access does not have native function for calculating prime. Requires custom function
http://stackoverflow.com/questions/1...vba-excel-2003
Apply criteria to filter records that are desired in the aggregation
SELECT Field3, Sum(field2) AS SumField2, Avg(field2) AS AvgField2 WHERE Field1="A" GROUP BY Field3;
OR
create fields with expressions that conditionally aggregate value
SELECT Field3, Sum(IIf([field1]="A",[Field2],0)) AS SumField2, Avg(IIf([Field1]="A",[Field2],0)) AS AvgField2 GROUP BY Field3;
Consider building a report that uses Grouping & Sorting functionality with aggregate calcs in group footers. This will allow display of detail records as well as summary calcs. The calcs from both query examples can be done in report.