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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Peony
Creator III
Creator III

Crosstable/generic load settings

Hi all.
I have a table similar to this:
Translate:
Load *Inline [
source,    ENG,                                     GER,                                                         3_let_code
s1,             English,                                Deutsch,                                                head_1
s1,             Select your language,  Bitte wählen Sie Ihre Sprache, head_2
s1,             Customer Feedback,    Kundenfeedback,                             head_3

];

And I need to make somehow crosstable load to receive this result:

head_1 head_2 head_3 3_let_code
English Select your language Customer Feedback ENG

Deutsch

Bitte wählen Sie Ihre Sprache Kundenfeedback GER


And unfortunately I can't get how to  get desired result. Maybe someone could help me with the idea how to deal with this issue?

Labels (2)
1 Solution

Accepted Solutions
cwolf
Creator III
Creator III

Translate:
Load * 
Inline[
source,ENG,GER,3_let_code
s1,English,Deutsch,head_1
s1,Selectyourlanguage,BittewählenSieIhreSprache,head_2
s1,CustomerFeedback,Kundenfeedback,head_3
];

// 1. Build a table with all languages from fieldnames
for i=1 to NoOfFields('Translate')
	fn=FieldName(i,'Translate')
	if not Match('$(fn)','source','3_let_code') then
		LangTab:
		load
		'$(fn)' as Language
		AutoGenerate 1;
	endif
next i

// 2. Generic load of all languages
for each lang in FieldValueList('Language')
	tmp:
	Generic LOAD
	'$(lang)' as Language,
	"3_let_code",
	"$(lang)"
	Resident Translate;
next lang

// 3. Join all generated tables
for i=NoOfTables() to 1 step -1
	let tn=TableName($(i));
	if WildMatch('$(tn)','tmp.*') then
		left join(LangTab)
		load * resident "$(tn)";
		
		drop table "$(tn)";
	end if
next i

// Finally
DROP table Translate;
RENAME Field Language to "3_let_code";

View solution in original post

2 Replies
cwolf
Creator III
Creator III

Translate:
Load * 
Inline[
source,ENG,GER,3_let_code
s1,English,Deutsch,head_1
s1,Selectyourlanguage,BittewählenSieIhreSprache,head_2
s1,CustomerFeedback,Kundenfeedback,head_3
];

// 1. Build a table with all languages from fieldnames
for i=1 to NoOfFields('Translate')
	fn=FieldName(i,'Translate')
	if not Match('$(fn)','source','3_let_code') then
		LangTab:
		load
		'$(fn)' as Language
		AutoGenerate 1;
	endif
next i

// 2. Generic load of all languages
for each lang in FieldValueList('Language')
	tmp:
	Generic LOAD
	'$(lang)' as Language,
	"3_let_code",
	"$(lang)"
	Resident Translate;
next lang

// 3. Join all generated tables
for i=NoOfTables() to 1 step -1
	let tn=TableName($(i));
	if WildMatch('$(tn)','tmp.*') then
		left join(LangTab)
		load * resident "$(tn)";
		
		drop table "$(tn)";
	end if
next i

// Finally
DROP table Translate;
RENAME Field Language to "3_let_code";
Peony
Creator III
Creator III
Author

Hey @cwolf  Thank you for a fresh ideas you shared😊. This solution definitely forks for me.