View Full Version : Conditional statement in a query expression.


gallagher
01-16-2002, 09:35 PM
Hi

I am trying to calculate a percentage amount based on a "Either/OR" condition.

The application is to give customers a percentage discount if their service is not working for a certain length of time. Example: If the time is > 6hrs AND < 36hrs then calculate 10% of the Monthly Bill and return this value, if > than 36hrs then calculate 15% of the Monthly Bill and return value. How does one do this in a query or report?

Regards
Darren

Thanks a lot, that worked fine.

[This message has been edited by gallagher (edited 01-21-2002).]

raskew
01-17-2002, 05:11 AM
Consider using the Switch() function in a calculated field in a query.
If, for example, you had fields [DownTime] and [TotBill] you could use something such as this.
Switch() works similar to Case Select in that it moves through the various options, selecting the first True statement.

Discount = Switch(DownTime>36, TotBill * 0.15, DownTime >= 6, TotBill * 0.10, True, 0)