Hi All,
The following is the SQL view from a query:
SELECT DISTINCT tblWOMods.PNMod, tblWOMods.Status, Sum(Nz([CompleteQuantity],0)) AS TotalCompQuant, Count(tblDefectLog.DefectPKID) AS DefectCount, Format([DefectCount]/[TotalCompQuant],"Percent") AS PerCentyld FROM tblWOMods INNER JOIN tblDefectLog ON tblWOMods.WOModsPKID = tblDefectLog.WOModsPKID GROUP BY tblWOMods.PNMod, tblWOMods.Status;
As you can see, if I have “NO” CompleteQuantity entered I’ll end up with a “divide-by-zero”, but it does work with a TotalCompQuant > 0.
So I tried:
PerCentYld: IIf([CompleteQuantity]0,Format([DefectCount]/[TotalCompQuant],"Percent"),0)
I then get the error:
“You tried to execute a query that does not include the specific expression
PerCentYld: IIf(Not [CompleteQuantity]=0,Format([DefectCount]/[TotalCompQuant],”Percent”),0)
as part of an aggregate function.
In the design view of the query the Total type is set to Expression.
So, what am I not doing (or doing what I shouldn’t) and how do I set this up correctly?
Thank you.