Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

msantarone
New 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
MVP
MVP

Re: Discount concatenated

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;

 

1 Reply
MVP
MVP

Re: Discount concatenated

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;

 

Community Browser