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

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
Qlikuser09
Creator II
Creator II

Data Load Editor for creating new table and converting columns to rows

I have two tables Table 1 and Table 2  . Both the tables are joined by a primary key Location Code.

Table 1

Location CodeEraserScalePenPencilSharpner
QWR24315
WER15366
RTY36574
FGH44683

 

Table 2

Location CodeEraserScalePenPencilSharpner
QWR32253
WER41164
RTY54345
FGH63436

 

Now I am trying to create a new table something like below with location code as the primary key and two new fields called product and Quantity , where Quantity = Table 1 values +Table 2 values

Location CodeProductQuantity
QWREraser5
QWRScale6
QWRPen 5
QWRPencil6
QWRSharpner8
WEREraser5
WERScale6
WERPen 9
WERPencil12
WERSharpner10
RTYEraser8
RTYScale10
1 Reply
Lisa_P
Employee
Employee

When you load the first two tables they should Autoconcatenate, so one table is created with rows from both data sources.

To Unpivot you reload the data again using the Crosstable prefix and drop the original table as per script below:


[Table1]:
LOAD * INLINE
[
Location Code,Eraser,Scale,Pen,Pencil,Sharpner
QWR,2,4,3,1,5
WER,1,5,3,6,6
RTY,3,6,5,7,4
FGH,4,4,6,8,3
](delimiter is ',');

LOAD * INLINE
[
Location Code,Eraser,Scale,Pen,Pencil,Sharpner
QWR,3,2,2,5,3
WER,4,1,1,6,4
RTY,5,4,3,4,5
FGH,6,3,4,3,6
](delimiter is ',');

NewTable:
CrossTable(Product, Quantity)
Load * Resident Table1;

Drop table Table1;

You can then get your result by summing the Quantity as per:

Lisa_P_0-1632961514191.png