Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
0li5a3a
Creator III
Creator III

New in QV and I need help

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!

1 Solution

Accepted Solutions
Peter_Cammaert
Partner - Champion III
Partner - Champion III

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

View solution in original post

6 Replies
Anonymous
Not applicable

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

Peter_Cammaert
Partner - Champion III
Partner - Champion III

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

makrishnaraj
Contributor III
Contributor III

Hi,

Can you please post sample data.

0li5a3a
Creator III
Creator III
Author

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:)

akpofureenughwu
Creator III
Creator III

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

0li5a3a
Creator III
Creator III
Author

Thanks for your help!

All good using your advise!