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: 
Not applicable

Intervals: inventory balance in time

Hello community, I've come across a situation that's been giving me some trouble the whole weekend... I think I'm at the point where I need some help:

I've got this table with the inventory records for each material and the interval of time where that inventory balance was valid.

MatIDStockStartEnd

A

101/08/201507/08/2015
A308/08/201513/08/2015
A514/08/201524/08/2015
A725/08/201525/08/2015
B201/08/201507/08/2015
B408/08/201515/08/2015
B616/08/201520/08/2015
B821/08/201525/08/2015

The intervals for each inventory record for each material may not be the same but there are not duplicates and each of them has both an start and an end date.

How could I combine this with a calendar table so that I am able, for example, to calculate the total inventory balance on 09/08/2015 ( 3 + 4 )?

Thanks in advance!

1 Solution

Accepted Solutions
MK_QSL
MVP
MVP

temp:

Load * Inline

[

  MatID, Stock, Start, End

  A, 1, 01/08/2015, 07/08/2015

  A, 3, 08/08/2015, 13/08/2015

  A, 5, 14/08/2015, 24/08/2015

  A, 7, 25/08/2015, 25/08/2015

  B, 2, 01/08/2015, 07/08/2015

  B, 4, 08/08/2015, 15/08/2015

  B, 6, 16/08/2015, 20/08/2015

  B, 8, 21/08/2015, 25/08/2015

];

NoConcatenate

Load

  MatID,

  Stock,

  Start,

  End,

  Date(Start + IterNo() - 1) as Date

Resident temp

while Start + IterNo() - 1 <= End;

Drop Table temp;

Now create a straight table

Dimension

Date

Expression

SUM(Stock)

View solution in original post

2 Replies
MK_QSL
MVP
MVP

temp:

Load * Inline

[

  MatID, Stock, Start, End

  A, 1, 01/08/2015, 07/08/2015

  A, 3, 08/08/2015, 13/08/2015

  A, 5, 14/08/2015, 24/08/2015

  A, 7, 25/08/2015, 25/08/2015

  B, 2, 01/08/2015, 07/08/2015

  B, 4, 08/08/2015, 15/08/2015

  B, 6, 16/08/2015, 20/08/2015

  B, 8, 21/08/2015, 25/08/2015

];

NoConcatenate

Load

  MatID,

  Stock,

  Start,

  End,

  Date(Start + IterNo() - 1) as Date

Resident temp

while Start + IterNo() - 1 <= End;

Drop Table temp;

Now create a straight table

Dimension

Date

Expression

SUM(Stock)

Not applicable
Author

Wow, that was fast.

Thank you very much!