Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

populate missing data

Hi all,

In the load script I want to populate missing data based on linear trend between 2 existing data points.

So for example my raw data is this:

DateValue
01/01/1210
02/01/129
04/01/127
05/01/126
08/01/123

So I want Qlikview to fill in the missing dates. I have a master calendar as follows and when I join the data above with it, I get this:

DateValue
01/01/1210
02/01/129
03/01/12
04/01/127
05/01/126
06/01/12
07/01/12
08/01/123


Simple linear calculation would allow me to determine that the value for 03/01/12 should be 8, simply by taking the 2 values either side of it.

How do I do this in the load script for a large data set.

Thanks

Dan

2 Replies
Miguel_Angel_Baeyens

Hi Dan,

Without knowing further on your datamodel, you can do another load statement RESIDENT the table joined, ordered by date, so if Value is empty, it adds the value from the previous record minus one:

NOCONCATENATE LOAD *,

     If(Len(Value) = 0, Previous(Value) -1, Value) AS Value

RESIDENT Table

ORDER BY Date ASC;

It could be possible to do this in one step, if the JOIN results on an already ordered table.

Hope that helps.

Miguel

Not applicable
Author

Thanks, but...

I used a simple relationship of -1 for the purposes of showing the example, but in reality the linear relationship between the dates will not be that simple. Example of real data:

DateValue
01/01/12356
02/01/12
03/01/12321
04/01/12318
05/01/12
06/01/12
07/01/12253


Useage is not constant, but I want to assume a linear relationship between 2 dates where a value is missing, and calculate what the intermediate value should be based on that linear regression.

I may have a gap of several days between values, not just one or two, and I need to populate several missing values based on a linear line between the known values either side.

Thanks