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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Find corresponding minimum value

Hi all,

Need help as after two days of efforts I am lost.

I have one master table and one history table where I need corresponding minimum values from history table. Let me explain in terms of data

Master table

IDDateJulianDate
10101/May/173000
10207/May/174000

History table

IDDateJulianDateValue
10101/May/1730001
10102/May/1730012
10103/May/1730023
10207/May/1740001
10208/May/1740014

Issue is I need data for 7 days where I have data for 3 days for ID 101 and 2 days for 102. Business logic is to capture the closest past date's "Value" from History table where dates are missing in 7 days. In case of ID 101, missing dates are 04,05,06 May and for these dates 03 May's "Value" should be used. In case of 102, for 06 May "Value" of 07 May should be used and for 09, 10, 11, 12, 13 May "Value" of 08 May should be used.

To achieve this I connected two tables with left join and created 7 Julian days columns (D1 -> D7) by adding 1 incrementally.

IDDateJulianDate1JulianDate2JulianDate3JulianDate4JulianDate5JulianDate6JulianDate7
10101/May/173000300130023003300430053006
10207/May/174000400140024003400440054006

Now I   subtracted Julian date of History from Master table to find difference in days. I created 7 difference columns carrying results of subtractions.

After this I ran Load Min(Diff1), ID, Value resident Master Group by ID, Value. This query goes running for 40 minutes before I aborted it. I am sure there will be a better way to do this in Qlik Script not UI.

I hope you can help. Thanks in advance.

0 Replies