App Development

Announcements
April 22, 2PM EST: Learn about GeoOperations in Qlik Sense SaaS READ MORE
cancel
Showing results for
Did you mean:
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
```TESTDATA:
*
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
];

Customer,
Discount#,
Discount,
If( Discount# = 1 , (1-Discount)*Amount , (1-Discount)*Peek('Amount') ) AS Amount
RESIDENT
TESTDATA
ORDER BY
Customer, [Discount#];

DROP TABLE TESTDATA;

```
MVP
```TESTDATA:
*
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
];