Qlik Community

Qlik Sense App Development

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

fnfrbr95
New Contributor II

Help working with batch, quantity and date

Hey guys, I need help.

I am working with a table that has the following structure:

Type|Batch|Date|Quantity

0001|XXXXX|2019-01-01|1000

0002|XXXXX|2019-01-02|100

0002|XXXXX|2019-01-03|100

0001|XXXXX|2019-01-04|50

0002|XXXXX|2019-01-06|100

What I need is to use all quantity in the first row (1000), type 0001, before using the quantity produced in 2019-01-04.

My Result should be:

Type|Batch|Date|Quantity

0001|XXXXX|2019-01-01|1000

0002|XXXXX|2019-01-02|100

0002|XXXXX|2019-01-03|100

0002|XXXXX|2019-01-06|100

0001|XXXXX|2019-01-04|50

It's basically a Sorting problem, the information type 0001 and type 0002 are in the same table and have the exactly same structure, but one is Items produced (0001) and the other are Items Sold (0002).

I need to sort them in a way that I only consume from a Batch that is previous to the Selling date and that I always get my quantity from the oldest remaining Batch produced (type 0001).

I hope you guys understand, if not, please ask me.

Thanks in advance.

2 Replies
Employee
Employee

Re: Help working with batch, quantity and date

Is the batch a number ? Can you load by batch  ascending ?

fnfrbr95
New Contributor II

Re: Help working with batch, quantity and date

The batch isn't always just numbers, it can be number and letters, it's already ascending considering batch and date, but as I showed new batches come out with same number/code before the older batch ends.