Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

create a new table in script by manipulating an existing table

I have an existing table with the columns as seen below (there are many more columns)

IDQ1Q2Q3Q4
15232
21510108

I need to create a new table in script as follows:

IDQuarterAmount
1Q15

2

Q115
1Q22
2Q210
1Q33
2Q310
1Q42
2Q48

where the Quarter column tells me which Quarter based on the column header in the first table (Q1, Q2, etc) and Amount captures the number value in that column.

I have no idea where to even begin with this, please help

1 Solution

Accepted Solutions
ecolomer
Master II
Master II

Is this??

p05.png

The script:

DATA:

LOAD * Inline [

ID, Q1, Q2, Q3, Q4

1, 5, 2, 3, 2

2, 15, 10, 10, 8

];

D_Q:

Load ID, 'Q1' as Quarter, Q1 as Value

resident DATA;

Load ID, 'Q2' as Quarter, Q2 as Value

resident DATA;

Load ID, 'Q3' as Quarter, Q3 as Value

resident DATA;

Load ID, 'Q4' as Quarter, Q4 as Value

resident DATA;

View solution in original post

4 Replies
ecolomer
Master II
Master II

Is this??

p05.png

The script:

DATA:

LOAD * Inline [

ID, Q1, Q2, Q3, Q4

1, 5, 2, 3, 2

2, 15, 10, 10, 8

];

D_Q:

Load ID, 'Q1' as Quarter, Q1 as Value

resident DATA;

Load ID, 'Q2' as Quarter, Q2 as Value

resident DATA;

Load ID, 'Q3' as Quarter, Q3 as Value

resident DATA;

Load ID, 'Q4' as Quarter, Q4 as Value

resident DATA;

rob_insley
Partner - Contributor III
Partner - Contributor III

Hi Shana,

A Cross Table is what you need.

TEmpData:

CrossTable(Quarter, Amount,1)

LOAD ID,

     Q1,

     Q2,

     Q3,

     Q4

FROM

C:\ProgramData\QlikTech\QlikView\QVExample.xlsx

(ooxml, embedded labels);

Capture.JPG

Thanks,

Rob

Not applicable
Author

Thank you Enrique this worked perfectly!!

Not applicable
Author

Thank you for your response Rob, this solution worked but how would I manipulate the numbers for this option? For example, I need 3 amounts - amount/1000, amount/1000*.2, and amount/1000*.4.

It also loaded all rows of the table but my original load only loads specific rows. how would I get around this?