Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
how to convert this table into below output:
This is exactly the challenge the Generic load prefix was designed to solve.
Here is a help article on the topic.
https://help.qlik.com/en-US/sense/latest/Subsystems/Hub/Content/Sense_Hub/DataSource/generic-databas...
Here is a link to unofficial blog that takes it a bit further and recombines the output of a generic load back into a single table:
https://qlikviewcookbook.com/2010/05/use-cases-for-generic-load/
Looking at your source table, you can translate it conceptually into this:
Key = Object
FieldName = Attribute
FieldValue = Value
OutputTable:
Generic
LOAD
Key,
FieldName,
FieldValue
from SomeTable;
One challenge I see in your sample data is, assuming the Key is a unique identifier, there seems to be multiple values for each attribute. Key2 seems to have SEVERAL addresses. This is not a problem per se, but something to keep an eye on.
Rajib,
As I said (in another post from yours here ), there is a missing link here. But you can approach creating the KEY based on your data order and it might be something like:
Emp:
Mapping Load * Inline [
EmpKey, EmpValue
key1, Name
key2, Address
key3, age
];
det2:
Load
detValue,
if(len(trim(detKey))=0, peek(detKey), detKey) as detKey
;
Load *
Inline [
detValue, detKey
1, key1
1,
Raju,
1,
2, key2
2,
cbe,
2,
3, key3
3,
3,
3,
];
NoConcatenate
temp:
Load * resident det2 Where not IsNum(detValue); //this is to match your output and disregard the other numeric values apart from 'Raju' and 'cbe';
Drop table det2;
det3:
Load detValue,
if(len(trim(detKey))=0, peek(detKey), detKey) as detKey
Inline [
detValue, detKey
Raja, key1
virat,
yuva,
try, key2
chn,
mad,
12, key3
14,
15,
16,
];
All:
Load
Autonumber( RowNo(),detKey) as KEY,
*
Resident temp;
Final:
Generic Load
KEY,
ApplyMap('Emp',detKey) as Attribute,
detValue as Value
Resident All;
Drop Table temp, All;
If this helps and you want to close it, close the other treads as well, please.
This is exactly the challenge the Generic load prefix was designed to solve.
Here is a help article on the topic.
https://help.qlik.com/en-US/sense/latest/Subsystems/Hub/Content/Sense_Hub/DataSource/generic-databas...
Here is a link to unofficial blog that takes it a bit further and recombines the output of a generic load back into a single table:
https://qlikviewcookbook.com/2010/05/use-cases-for-generic-load/
Looking at your source table, you can translate it conceptually into this:
Key = Object
FieldName = Attribute
FieldValue = Value
OutputTable:
Generic
LOAD
Key,
FieldName,
FieldValue
from SomeTable;
One challenge I see in your sample data is, assuming the Key is a unique identifier, there seems to be multiple values for each attribute. Key2 seems to have SEVERAL addresses. This is not a problem per se, but something to keep an eye on.
Rajib,
As I said (in another post from yours here ), there is a missing link here. But you can approach creating the KEY based on your data order and it might be something like:
Emp:
Mapping Load * Inline [
EmpKey, EmpValue
key1, Name
key2, Address
key3, age
];
det2:
Load
detValue,
if(len(trim(detKey))=0, peek(detKey), detKey) as detKey
;
Load *
Inline [
detValue, detKey
1, key1
1,
Raju,
1,
2, key2
2,
cbe,
2,
3, key3
3,
3,
3,
];
NoConcatenate
temp:
Load * resident det2 Where not IsNum(detValue); //this is to match your output and disregard the other numeric values apart from 'Raju' and 'cbe';
Drop table det2;
det3:
Load detValue,
if(len(trim(detKey))=0, peek(detKey), detKey) as detKey
Inline [
detValue, detKey
Raja, key1
virat,
yuva,
try, key2
chn,
mad,
12, key3
14,
15,
16,
];
All:
Load
Autonumber( RowNo(),detKey) as KEY,
*
Resident temp;
Final:
Generic Load
KEY,
ApplyMap('Emp',detKey) as Attribute,
detValue as Value
Resident All;
Drop Table temp, All;
If this helps and you want to close it, close the other treads as well, please.