Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi guys,
I 'm new in QV and I need to create o new column into my Table.
tablename:
load
[Sales Price],
[Voucher Amount],
from
my.qvd
I would like to create a new column into my table using if statement.
tablename:
load
[Sales Price],
[Voucher Amount],
if(([Voucher Amount] > 30%from [Sales Price]) then 0%),
if(([Voucher Amount] = 30% from [Sales Price]) then 10%),
f(([Voucher Amount] = 30% from [Sales Price]) then 10%))) as Commission
from
my.qvd
Thanks in advance!
In LOAD statements, you'll be using the IF() functions with two or three parameters. The THEN and ELSE roles will be fulfilled by the second and third parameters. Read up on the IF() function in the chapter on Conditional Functions in QV Desktop Help.
Also, percentage cannot be handled like this. OTOH a 30% value comes down to a ratio of 0.3, so checking whether Voucher Amount is greater than 30% of Sales Amount can be written as:
IF ([Voucher Amount]/[Sales Amount] > 0.3, 0, IF (..., , IF (...))) AS Commission
Best,
Peter
try this: twice 10% is that correct??
tablename:
load
[Sales Price],
[Voucher Amount],
if(([Voucher Amount] > 0.3*[Sales Price]) then 0),
if(([Voucher Amount] = 0.3*[Sales Price]) then 10),
f(([Voucher Amount] = 30% from [Sales Price]) then 10))) as Commission
from
my.qvd
do you want commission ondetail base or on Group base
In LOAD statements, you'll be using the IF() functions with two or three parameters. The THEN and ELSE roles will be fulfilled by the second and third parameters. Read up on the IF() function in the chapter on Conditional Functions in QV Desktop Help.
Also, percentage cannot be handled like this. OTOH a 30% value comes down to a ratio of 0.3, so checking whether Voucher Amount is greater than 30% of Sales Amount can be written as:
IF ([Voucher Amount]/[Sales Amount] > 0.3, 0, IF (..., , IF (...))) AS Commission
Best,
Peter
Hi,
Can you please post sample data.
Hi Rudolf,
Thanks for your answer!
my last table suppose to be like this
tablename:
load
[Sales Price],
[Voucher Amount],
if(([Voucher Amount] > 30%from [Sales Price]) then 0%),
if(([Voucher Amount] = 30% from [Sales Price]) then 10%),
if(([Voucher Amount] = 20% from [Sales Price]) then 20%))) as Commission
from
my.qvd
Sorry this is what I want:)
Try this:
tablename:
load
[Sales Price],
[Voucher Amount],
IF ([Voucher Amount]/[Sales Amount] > 0.3, 0,
IF (([Voucher Amount]/[Sales Amount] =< 0.3, 10, )) AS Commission
from
my.qvd
Thanks for your help!
All good using your advise!