Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
msantarone
Contributor
Contributor

Discount concatenated

I need to solve  in a load from a result of a previous row.

I have the following problem:

I have a table with discount rates to apply:

Customer discount Percentage

1 1 25%

1 2 10%

1 3 15%

The drawback is that the discounts are concatenated, so that the results would be for a price of 100:

Customer discount Percentage

1 1 25% - 75

1 2 10% - 67.50

1 3 15% - 57.38

How can I solve it in a Qlik LOAD?

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

TESTDATA:

LOAD

  *

INLINE

[Customer, Discount#, Discount, Amount

  1, 1, 25%, 100

  2, 1, 10%, 500

  1, 2, 10%, 100

  2, 2, 15%, 500

  1, 3, 15%, 100

];

NOCONCATENATE LOAD

  Customer,

  Discount#,

  Discount,

  If( Discount# = 1 , (1-Discount)*Amount , (1-Discount)*Peek('Amount') ) AS Amount

RESIDENT

  TESTDATA

ORDER BY

Customer, [Discount#];

 

DROP TABLE TESTDATA;

 

View solution in original post

1 Reply
petter
Partner - Champion III
Partner - Champion III

TESTDATA:

LOAD

  *

INLINE

[Customer, Discount#, Discount, Amount

  1, 1, 25%, 100

  2, 1, 10%, 500

  1, 2, 10%, 100

  2, 2, 15%, 500

  1, 3, 15%, 100

];

NOCONCATENATE LOAD

  Customer,

  Discount#,

  Discount,

  If( Discount# = 1 , (1-Discount)*Amount , (1-Discount)*Peek('Amount') ) AS Amount

RESIDENT

  TESTDATA

ORDER BY

Customer, [Discount#];

 

DROP TABLE TESTDATA;