# Thread: If..Then.. function in a report

1. ## If..Then.. function in a report

I think this one should be straight forward, but i cannot find anything in the forum which directly addresses my request.

Basically, i have two numerical fields in my report.

field 1: Quantity
field 2: Cost

I wish to put in place a calculation which determines the cost depending on the quantity. e.g.

0 - 999 = 100.00
1000 - 3999 = 200.00
4000 - 7999 = 300.00
8000 - 11999 = 400.00
12000 and above = 500.00

Can anyone tell me how i can achieve this?

Denis

2. ## Re: If..Then.. function in a report

Code:
`case(Quantity<1000,100.00,Quantity<4000,200.00,Quantity<8000,300.00,Quantity<12000,400.00,.t.,500.00)`
The case statement uses the first true statement from the left. The last test is .t. which acts as a default if all the previous tests fail.

3. ## Re: If..Then.. function in a report

Tim,

Thank you for the speedy response. This bit of Alpha is new to me, can you tell me where the case statement should be placed.

Thanks again.

Denis

4. ## Re: If..Then.. function in a report

Originally Posted by den1s
Tim,

Thank you for the speedy response. This bit of Alpha is new to me, can you tell me where the case statement should be placed.

Thanks again.

Denis
Denis,

with the report in design mode click the xy button on the main alpha toolbar. This opens the Calculated values dialog. Enter a new line containing "cost =" (no quotes) and the expression from the previous post. Or enter "cost =' and press f10 to invoke the expresion builder where you can build the expression. After entering press OK until you are back to the form design.

Then from the drag drop list choose the newly created calculation and place it into the detail section of the report.

5. ## Re: If..Then.. function in a report

Quick, Slick, Perfect!!!

Thank you.

6. ## Re: If..Then.. function in a report

Originally Posted by den1s
Quick, Slick, Perfect!!!

Thank you.
Your welcome. The fact you are Alpha fiving hopefully means you don't need to be outside sand bagging your house. :)

7. ## Re: If..Then.. function in a report

We were lucky in London as we escaped the worst of it. So far....

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•