Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in NYC Sept 4th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
dbosboom
Partner - Contributor II
Partner - Contributor II

Stock information based on latest EMPTY message.

 

Hi all,

First of all thanks in advance for helping! This community has been a huge help for me so far without even needing to post something. The time has finally arrived that I have to post something as I have not been able to find the right answer. The following has been keeping me busy for the last 2 days.

A customer wants to see the day-to-day stock information of their products per silo. Meaning that they select a date and they want to see everything that has been added to or used from that silo, previous to that date.

Their system creates a row in the database each time the silo is completely empty, meaning that I only have to calculate the stock from the selected date back in time until the first “Empty” message. Everything before this message is irrelevant.

I’ve tried coming up with a decent illustration of what I mean. See below:

DateTimeWeight(kg)SiloCode
25/02/201604:00+20006008
25/02/201603:45+10006007
24/02/201623:01+10006006
24/02/201614:5106EMPTY
24/02/201614:50-67006005
24/02/201614:42+23006004
24/02/201614:32+34006003
24/02/201613:58-14006002
24/02/201613:42+24006001


Let´s say they have selected the 25th of February and silo 6. They now need only need to see the rows with code 006, 007 and 008.

 

My set analysis looks like this: SUM({<Date = {"<=$(=Max(Date))"}>}Weight)

But this also shows all the rows before the empty message. 

I’ve also tried: =SUM({<Datum = {">=$(=Min({<Code = {'EMPTY'}>} Date)) <=$(=Max(Date))"}>}Weight) to get the minimum date with the code EMPTY but there can be more than 1 when going back in time.

Do you guys have any idea how to find the first EMPTY value prior to the selected date?

Thanks!

11 Replies
sunny_talwar

Try this:

=Sum({<Date = {">=$(=Date(Max({<Date = {'<=$(=Max(Date))'}, Code = {'Leegmelden'}>} Date))) <=$(=Max(Date))"}>}Weight)

dbosboom
Partner - Contributor II
Partner - Contributor II
Author

So far this works! Thanks tresesco and Sunny T! (Can't tag you somehow)