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

Table load using another table

PackageIDValue
Misusing DD11
Missing Bag22
Missing Box34

The above table I have , I need to create new table below:

PackageValue
Misusing DD1
Missing Bag2
Misusing DD, Missing Bag3
Misusing DD, Missing Box5
Missing Bag, Missing Bag6
Misusing DD, Missing Bag, Missing Box7

How to get the table like this? in QlikView Script

1 Solution

Accepted Solutions
MarcoWedel

Hi,

one solution could be also:

QlikCommunity_Thread_299774_Pic1.JPG

table1:

LOAD * FROM [https://community.qlik.com/thread/299774] (html, codepage is 1252, embedded labels, table is @1);

mapPackage:

Mapping LOAD Value, Package Resident table1;

table2:

LOAD Concat(Package,', ',OrdNo) as Package, Value

Group By Value;

LOAD RecNo() as Value,

    IterNo() as OrdNo,

    ApplyMap('mapPackage',RecNo() bitand (1<<(IterNo()-1)),Null()) as Package

AutoGenerate 1<<FieldValueCount('Package')-1

While IterNo()<=FieldValueCount('Package');

DROP Table table1;

hope this helps

regards

Marco

View solution in original post

6 Replies
eduardo_dimperio
Specialist II
Specialist II

Do you need  to do all combinations or just that ones?

Anonymous
Not applicable
Author

I need all combinations like recursive self  join sql

eduardo_dimperio
Specialist II
Specialist II

//***********************************************************

BASE:

load * inline [

PACKAGE,VALUE

Misusing DD,1

Missing Bag,2

Missing Box,4

];

//***********************************************************

NoConcatenate

AUX_TB1:

LOAD

PACKAGE AS PACKAGE1,

VALUE   AS VALUE1

RESIDENT BASE;

Inner Join(AUX_TB1)

LOAD

PACKAGE AS PACKAGE2,

VALUE   AS VALUE2

RESIDENT BASE;

NoConcatenate

AUX_TB2:

LOAD

*

RESIDENT AUX_TB1;

Inner Join(AUX_TB2)

LOAD

PACKAGE AS PACKAGE3,

VALUE   AS VALUE3

RESIDENT BASE;

//*********************************************

Concatenate(BASE)

LOAD

PACKAGE1 &','& PACKAGE2  AS PACKAGE,

VALUE1 +VALUE2 AS VALUE

RESIDENT AUX_TB1;

Concatenate(BASE)

LOAD

PACKAGE1 &','& PACKAGE2 &','& PACKAGE3  AS PACKAGE,

VALUE1 +VALUE2 +VALUE3 AS VALUE

RESIDENT AUX_TB2;

//*********************************************

DROP TABLE AUX_TB1;

DROP TABLE AUX_TB2;

EXIT SCRIPT;

MarcoWedel

Hi,

one solution could be also:

QlikCommunity_Thread_299774_Pic1.JPG

table1:

LOAD * FROM [https://community.qlik.com/thread/299774] (html, codepage is 1252, embedded labels, table is @1);

mapPackage:

Mapping LOAD Value, Package Resident table1;

table2:

LOAD Concat(Package,', ',OrdNo) as Package, Value

Group By Value;

LOAD RecNo() as Value,

    IterNo() as OrdNo,

    ApplyMap('mapPackage',RecNo() bitand (1<<(IterNo()-1)),Null()) as Package

AutoGenerate 1<<FieldValueCount('Package')-1

While IterNo()<=FieldValueCount('Package');

DROP Table table1;

hope this helps

regards

Marco

Anonymous
Not applicable
Author

Thank you Marco, It is working as expected

eduardo_dimperio
Specialist II
Specialist II

Hi Marco,

I really tried, but dont get how this works and why you choose this way. Can you explain please?

I follow your code and you(i think):

Deslocate  the InterNo()-1 in 1 bit (why?)

After, you use a comparisson between bits using bitand (why???)

and then you aply the mapping, but mapping dont need to be use in a comon field, you use in RecNo() bitand (1<<(IterNo()-1)) (why??!!??)

I'm really confuse about it