## Need help from the experts building up an expression in a VFP9 report

## Need help from the experts building up an expression in a VFP9 report

(OP)

I currently have the following fields in a report;

qtyship = 6

price = 1.15

disc_num = 5 (this is stored as a number but would be treated as a percentage when calculating)

discount = y (this can be either "Y" or "N"

I want to be able to subtract PRICE - DISC_NUM only when Discount = "Y" and then multiply by qtyship

On the fields above it would be 1.15 - 5% = 1.0925 but would need to be round off to 1.09

therefore 6 * 1.09 = 6.54

But like I mentioned, it would only calculate the percentage where Discount = "Y".

I can't figure this out any help would be much apreciated

Thank you

qtyship = 6

price = 1.15

disc_num = 5 (this is stored as a number but would be treated as a percentage when calculating)

discount = y (this can be either "Y" or "N"

I want to be able to subtract PRICE - DISC_NUM only when Discount = "Y" and then multiply by qtyship

On the fields above it would be 1.15 - 5% = 1.0925 but would need to be round off to 1.09

therefore 6 * 1.09 = 6.54

But like I mentioned, it would only calculate the percentage where Discount = "Y".

I can't figure this out any help would be much apreciated

Thank you

## RE: Need help from the experts building up an expression in a VFP9 report

## CODE -->

This is simplyfied to clearly point out the IIF usege, you'll get the discountprice correct. Take a look at ROUND(number,decimalplaces) to round to 2 decimal places.

Bye, Olaf.

## RE: Need help from the experts building up an expression in a VFP9 report

Im able to get the right number when I do the following

round2((1-disc-num/100)*(.price)) but if I add IIF(discount='Y',round2((1-disc-num/100)*(.price))) VFP tells me theres a comma missing, what am i doing wrong?

Thank you

## RE: Need help from the experts building up an expression in a VFP9 report

Tamar

## RE: Need help from the experts building up an expression in a VFP9 report

If there is no discount, you want the unmodified price.

Aside of that I don't know where you get a "round2" function from, VFP has ROUND(num,2).

Also I don't see a WITH....ENDWITH, so how would ".price" work?

Are you talking about a VFP report here, at all?

Bye, Olaf.

## RE: Need help from the experts building up an expression in a VFP9 report

Yes, is in a report, I have everything working as requested thanks to your instructions. Now i'm having a little problem getting to print a field where i'm multiplying qtyship*price but only print when discount is either 'N' or empty. What expression can I use?

Thank you

## RE: Need help from the experts building up an expression in a VFP9 report

You don't need two expressions for 'Y' and 'N'.

Bye, Olaf.

## RE: Need help from the experts building up an expression in a VFP9 report

## CODE -->

Also read the help topic of commands you don't know yet, to understand them. https://msdn.microsoft.com/it-it/library/7ttt15k6(...

Bye, Olaf.

## RE: Need help from the experts building up an expression in a VFP9 report

Thank you