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: 
Vishal
Contributor II
Contributor II

Generic Load is not working on Date with Slash or hyphen or [Full Name]

Hello Everyone, 

Thanks for the help in advance. I am stuck at Generic Load, wherein I need to convert Date as 15-04-16 to Column name, or a value with full name, such as 'Other Users'. 

I have attached a file here, which contain three scenarios. Please have a look. 

I have table as below, but dates are as 15-04-16 or in some cases - Other Uses.

Vishal_0-1661189338998.png

And I want to transpose the above table as below. 

Vishal_1-1661189466942.png

For this, I have used below script - 

Ind:
Load * Inline[
Date, Indication_flag, NPS
15Apr16, NPS, 2
26Apr16, NPS, 3
27Apr16, NPS, 4
29Apr16, NPS, 5
30Apr16, NPS, 6
];

NTranspose:
Generic LOAD
Indication_flag, Date as Date, NPS
Resident Ind;

NoConcatenate
Data:
Load Distinct Indication_flag Resident Ind;

For i=0 to NoOfTables()

TableList:
LOAD
TableName($(i)) as TableName
AutoGenerate 1
Where WildMatch(TableName($(i)), 'NTranspose*');

NEXT i

For j=1 to FieldValueCount('TableName')

LET vTable = FieldValue('TableName', $(j));
Left Join(Data) LOAD * Resident $(vTable);
Drop Table $(vTable);

Next j
Drop Tables Ind, TableList;

Now, wherever there is a date containing hyphen or slash, or full name as value, I get below error. Kindly help!

Vishal_3-1661189911025.png

Vishal_4-1661190009865.png

 

Thanks for the help!

 

 

Labels (2)
1 Solution

Accepted Solutions
Taoufiq_Zarra

@Vishal 

can you try this proposition :

Input:
load * inline [
Date,Indicate_flag,NPS
15Apr16,NPS,2
26Apr16,NPS,3
27Apr16,NPS,4
29Apr16,NPS,5
30Apr16,NPS,6
];

DATA:
 Generic LOAD
 
 Indicate_flag, 
 Date, 
 NPS
 Resident Input;
     


 
output:

Load distinct Indicate_flag  resident Input;
 Drop Table   Input;
   

FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  //trace $(i) - '$(vTable)';
  IF WildMatch('$(vTable)', 'DATA.*') THEN 

  LEFT JOIN ([output]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i

 

input:

Taoufiq_Zarra_0-1661197291205.png

output:

Taoufiq_Zarra_1-1661197328654.png

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉

View solution in original post

2 Replies
Taoufiq_Zarra

@Vishal 

can you try this proposition :

Input:
load * inline [
Date,Indicate_flag,NPS
15Apr16,NPS,2
26Apr16,NPS,3
27Apr16,NPS,4
29Apr16,NPS,5
30Apr16,NPS,6
];

DATA:
 Generic LOAD
 
 Indicate_flag, 
 Date, 
 NPS
 Resident Input;
     


 
output:

Load distinct Indicate_flag  resident Input;
 Drop Table   Input;
   

FOR i = NoOfTables()-1 to 0 STEP -1

  LET vTable=TableName($(i));
  //trace $(i) - '$(vTable)';
  IF WildMatch('$(vTable)', 'DATA.*') THEN 

  LEFT JOIN ([output]) LOAD distinct * RESIDENT [$(vTable)];

  DROP TABLE [$(vTable)];

  ENDIF 

NEXT i

 

input:

Taoufiq_Zarra_0-1661197291205.png

output:

Taoufiq_Zarra_1-1661197328654.png

 

Regards,
Taoufiq ZARRA

"Please LIKE posts and "Accept as Solution" if the provided solution is helpful "

(you can mark up to 3 "solutions") 😉
Vishal
Contributor II
Contributor II
Author

Thanks @Taoufiq_Zarra ! it worked for me.