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

Adding missing rows for missing dates to a fact without join

Hi,

I have a source table with "account", "date", "value"

I want to load that table and adding for each account the missing dates with empty value from his minimum date to the maximum date in the source table

This needs to be done in one load (preceding load are ok)

Anyone have an idea how to do this?

Thanks

 

3 Replies
Marco
Partner - Contributor III
Partner - Contributor III

Hi, 

You can try with this:

Table:
NoConcatenate
LOAD
Account,
Date,
Value
From 
Source
;

Calendar:
NoConcatenate
LOAD
Account,
Min(Date) as DateMin,
Max(Date) as DateMax 
Resident
Table
Group By
Account;

Join (Table)
LOAD
Account,
Date(iterno()+MinDate) as Date
Resident
Calendar
While iterno()+MinDate <= MaxDate
;
Drop Table Date;

Anonymous
Not applicable
Author

this was my first try

i`m working on a very large data set, can`t use join.

needs to be done in one load of the source table, can be done with preceding load.

 

tamilarasu
Champion
Champion

I hope this will not take much time since we are taking resident of only two fields from main table and concatenating with main table.

Data:
Load
Account & Date as TempKey,
Account,
Date,
Value
FROM Source;

Concatenate (Data)
Data:
Load * where not Exists(TempKey);
LOAD Account & date(Min -1 + IterNo(),'DD/MM/YYYY') as TempKey,
Account,
date(Min -1 + IterNo(),'DD/MM/YYYY') as Date,
'' as Value
While IterNo() <= Max - Min +1;
LOAD Account, Max(Date) as Max,
Min(Date) as Min
Resident Data Group By Account;

DROP Field TempKey;