Query calculation help needed

Sketchin

Registered User.
Local time
Today, 05:12
Joined
Dec 20, 2011
Messages
580
I have an expression as such:
Code:
LeaseCost: IIf([tblCompanies].[Portfolio]=0,Sum(([DailyRate]*[workingdays])),0)

How would I go about summing [LeaseCost]? I tried:
Code:
PreDiscount: Sum(IIf([tblCompanies].[Portfolio]=0,(Sum([DailyRate]*[workingdays])),0))

but I get an error saying "Cannot have aggregate function in expression"

I wish I could just do Prediscount: Sum([LeaseCost])

THanks
 
have you tried :

(Sum(IIf([tblCompanies].[Portfolio]=0,(Sum([DailyRate]*[workingdays])),0))) as LeaseCost, Sum([LeaseCost])
 
It doesn't like the "As" part. Says invalid expression
 
Figured it out...just putting =Sum([Leasecost]) on my report in a textbox, rather than doing the calculation in the query itself.

Thanks for the input though!
 
Sorry, I if you are in Design View of Query :

1st column:

LeaseCost: IIf([tblCompanies].[Portfolio]=0,Sum(([DailyRate]*[workingdays])),0)


2nd column:

PreDiscount: Sum(LeaseCost)


The query would first evaluate LeaseCost, and next go on to Taking value in LeaseCost column ( number) and evaluate PreDiscount

So it won't evaluate this huge equation again to calculate PreDiscount
 

Users who are viewing this thread

Back
Top Bottom