Query Expression with IF???

mnunan

Registered User.
Local time
Today, 12:28
Joined
Apr 22, 2013
Messages
13
Hello all

I need a little help with a query please. I have a report based on a query which has some calculated fields.

Subtotal: ([journey_price]/100*90) is an expression in the query which deducts 10% off of the journey price. This is then used for other calculations.

What I need to do is have that expression not apply (i.e. remain at 100%) if the 'waive' field is yes/true.

Is this possible in the expression and if so how please?

Thanks :)
 
For something like this, you use the immediate if. In this case, you're looking for something like this:

Code:
Subtotal: Iif([Waive],[journey_price],[journey_price]*0.9)

This example assumes that [Waive] is a boolean field. The first parameter must evaluate to True or False, otherwise.
 
try

Subtotal: [journey_price]*iif([waive]=true,1,90/100)
 
Try something like,
Code:
Subtotal: [journey_price]/100 * IIF(yourField = True, 90, 100)
 
Thanks very much everyone, I used CJs example and it works perfectly.

Much appreciated.
 

Users who are viewing this thread

Back
Top Bottom