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

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Incremental Load of FlatTable

I have a table which has the following structure:

ProdID, CustomerID, Year, Amount1, Marge1, Cost1, Amount2, Marge2, Cost2, Amount3, Marge3, Cost3,...,...,...,...


Where 1,2,3,.. are the months. So the table is in an odd structure.

What would be the best way to incremental Load that table.

My approach:


table1:
LOAD
ProdID,
CustomerID,
Year,
Amount1,
Marge1,
Cost1
FROM source;

CONCATANATE(tabe1)
LOAD
ProdID,
CustomerID,
Year,
Amount1,
Marge1,
Cost1
FROM source;



But this gives me too many ProdID's and CustomerID's. Is that a problem?
Any help is appreciated!

1 Solution

Accepted Solutions
johnw
Champion III
Champion III

What do you want the final result to be? Something like this?

ProdID, CustomerID, Year, Month, Amount, Marge, Cost

If so, look into doing a CROSSTABLE load. There might be an easier way, and I probably have bugs, but perhaps something like this:

Raw:
LOAD
recno() as Recno
,ProdID
,CustomerID
,Year
,Amount1
,Amount2
...
,Amount12
,Marge1
,Marge2
...
,Marge12
,Cost1
,Cost2
...
,Cost12
FROM Source
;
New:
CROSSTABLE (Month,Amount,4)
LOAD
Recno
,ProdID
,CustomerID
,Year
,Amount1 as 1
,Amount2 as 2
...
,Amount12 as 12
RESIDENT Raw
;
LEFT JOIN (New)
CROSSTABLE (Month,Marge)
LOAD
Recno
,Marge1 as 1
,Marge2 as 2
...
,Marge12 as 12
RESIDENT Raw
;
LEFT JOIN (New)
CROSSTABLE (Month,Cost)
LOAD
Recno
,Cost1 as 1
,Cost2 as 2
...
,Cost12 as 12
RESIDENT Raw
;

As for turning that into an incremental load, I'd need more information. Is "source" a file? A database? A QVD? How is data added to "source"? On what schedule? Can records be deleted from "source"? Can they be changed? Or can they only be added? What advantage are you hoping to gain by going to an incremental reload?

View solution in original post

1 Reply
johnw
Champion III
Champion III

What do you want the final result to be? Something like this?

ProdID, CustomerID, Year, Month, Amount, Marge, Cost

If so, look into doing a CROSSTABLE load. There might be an easier way, and I probably have bugs, but perhaps something like this:

Raw:
LOAD
recno() as Recno
,ProdID
,CustomerID
,Year
,Amount1
,Amount2
...
,Amount12
,Marge1
,Marge2
...
,Marge12
,Cost1
,Cost2
...
,Cost12
FROM Source
;
New:
CROSSTABLE (Month,Amount,4)
LOAD
Recno
,ProdID
,CustomerID
,Year
,Amount1 as 1
,Amount2 as 2
...
,Amount12 as 12
RESIDENT Raw
;
LEFT JOIN (New)
CROSSTABLE (Month,Marge)
LOAD
Recno
,Marge1 as 1
,Marge2 as 2
...
,Marge12 as 12
RESIDENT Raw
;
LEFT JOIN (New)
CROSSTABLE (Month,Cost)
LOAD
Recno
,Cost1 as 1
,Cost2 as 2
...
,Cost12 as 12
RESIDENT Raw
;

As for turning that into an incremental load, I'd need more information. Is "source" a file? A database? A QVD? How is data added to "source"? On what schedule? Can records be deleted from "source"? Can they be changed? Or can they only be added? What advantage are you hoping to gain by going to an incremental reload?